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

public class bfs_vd {
	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[] sum;
	long[] dist;
	long[] d2;

	void dfs(int v, int par) {
		sum[v] = 1;
		for (Edge x : a[v]) {
			int i = x.to;
			long cst = x.cost;
			if (i != par) {
				dfs(i, v);
				sum[v] += sum[i];
				dist[v] = dist[v] + dist[i] + sum[i] * cst;
				d2[v] = d2[v] + d2[i] + 2 * dist[i] * cst + sum[i] * cst * cst;
			}
		}
	}

	int n;
	long[] cnt;

	void count(int v, int par, long dst2, long dst) {
		dst2 += d2[v];
		dst += dist[v];
		cnt[v] = dst2;
		if (dst2 < min) {
			min = dst2;
		}
		for (Edge x : a[v]) {
			int i = x.to;
			long cst = x.cost;
			if (i != par) {
				long cur2 = dst2 - d2[i] - 2 * dist[i] * cst - sum[i] * cst
						* cst;
				long cur = dst - dist[i] - sum[i] * cst;
				count(i, v, cur2 + 2 * cur * cst + (n - sum[i]) * cst * cst,
						cur + (n - sum[i]) * cst);
			}
		}

	}

	ArrayList<Integer> res = new ArrayList<Integer>();
	long min = Long.MAX_VALUE;

	void solve() throws IOException {
		n = nextInt();
		sum = new int[n];
		dist = new long[n];
		d2 = new long[n];
		a = new ArrayList[n];
		cnt = new long[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));
		}
		dfs(0, -1);
		count(0, -1, 0, 0);
		for (int i = 0; i < n; i++) {
			if (cnt[i] == min) {
				res.add(i + 1);
			}
		}

		out.println(res.size());
		for (int i = 0; i < res.size() - 1; i++) {
			out.print(res.get(i) + " ");
		}
		out.println(res.get(res.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().run();
	}
}
