import java.io.*;
import java.util.*;


public class bfs_vd_tl {
	BufferedReader in;
	StringTokenizer str;
	PrintWriter out;
	String SK;

	String next() throws IOException {
		while ((str == null) || (!str.hasMoreTokens())) {
			SK = in.readLine();
			if (SK == null)
				return null;
			str = new StringTokenizer(SK);
		}
		return str.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	class Edge {
		int to;
		int cost;

		public Edge(int a, int b) {
			to = a;
			cost = b;
		}
	}

	ArrayList<Edge>[] a;
	int n;

	long bfs(int v) {
		int[] dist = new int[n];
		dist[v] = 1;
		Queue<Integer> que = new ArrayDeque<Integer>();
		que.add(v);
		while (!que.isEmpty()) {
			v = que.poll();
			for (Edge i : a[v]) {
				if (dist[i.to] == 0) {
					dist[i.to] = dist[v] + i.cost;
					que.add(i.to);
				}
			}
		}
		long res = 0;
		for (int i = 0; i < n; i++) {
			long t = dist[i];
			res = res + (t - 1) * (t - 1);
		}
		return res;
	}

	void solve() throws IOException {
		n = nextInt();
		a = new ArrayList[n];
		for (int i = 0; i < n; i++) {
			a[i] = new ArrayList<Edge>();
		}
		for (int i = 0; i < n - 1; i++) {
			int st = nextInt() - 1;
			int en = nextInt() - 1;
			int cst = nextInt();
			a[st].add(new Edge(en, cst));
			a[en].add(new Edge(st, cst));
		}
		long[] res = new long[n];
		long opt = Long.MAX_VALUE;

		for (int i = 0; i < n; i++) {
			res[i] = bfs(i);
			opt = Math.min(opt, res[i]);
		}
		ArrayList<Integer> resul = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			if (res[i] == opt) {
				resul.add(i + 1);
			}
		}
		out.println(resul.size());
		for (int i = 0; i < resul.size() - 1; i++) {
			out.print(resul.get(i) + " ");
		}
		out.println(resul.get(resul.size() - 1));
	}

	void run() throws IOException {
		in = new BufferedReader(new FileReader("bfs.in"));
		out = new PrintWriter("bfs.out");
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new bfs_vd_tl().run();
	}
}
