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

public class bfs_pk2 {

	PrintWriter out;
	BufferedReader br;
	StringTokenizer st;

	String nextToken() throws IOException {
		while ((st == null) || (!st.hasMoreTokens()))
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

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

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

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

	class Edge {
		int cost, to;

		public Edge(int to, int cost) {
			super();
			this.cost = cost;
			this.to = to;
		}

		@Override
		public String toString() {
			return "Edge [cost=" + cost + ", to=" + to + "]";
		}

	}

	public void solve() throws IOException {
		int n = nextInt();
		ArrayList<Edge>[] e = new ArrayList[n];
		for (int i = 0; i < n; i++)
			e[i] = new ArrayList<bfs_pk2.Edge>();
		for (int i = 0; i < n - 1; i++) {
			int x = nextInt() - 1;
			int y = nextInt() - 1;
			int c = nextInt();
			e[x].add(new Edge(y, c));
			e[y].add(new Edge(x, c));
		}
		boolean[] was = new boolean[n];
		int[] longest = new int[n];
		dfs(0, e, was, longest, -1);
		//System.err.println(Arrays.toString(longest));
		was = new boolean[n];
		int[] goodLongest = new int[n];
		dfs2(0, e, was, longest, goodLongest, -1, 0);
		//System.err.println(Arrays.toString(goodLongest));

		int min = 0;
		for (int i = 1; i < n; i++)
			if (goodLongest[i] < goodLongest[min]) {
				min = i;
			}

		was = new boolean[n];
		ArrayList<Integer> q = new ArrayList<Integer>();
		q.add(min);
		was[min] = true;
		ArrayList<Integer> ans = new ArrayList<Integer>();
		//System.err.println(Arrays.deepToString(e));
		long minRes = Long.MAX_VALUE;
		System.err.println(":)");
		for (int i = 0; i < Math.min(q.size(), 35); i++) {
			int t = q.get(i);
			for (Edge ee : e[t]) {
				if (!was[ee.to]) {
					q.add(ee.to);
					was[ee.to] = true;
				}
			}
			boolean[] was2 = new boolean[n];
			long res = dfs3(t, was2, 0, e);
			if (res < minRes) {
				minRes = res;
				ans = new ArrayList<Integer>();
			}
			if (res == minRes) {
				ans.add(t);
			}
			//System.err.println(t);
			//if (i % 10 == 0)
				//System.err.println(i);
		}
		out.println(ans.size());
		for (int x : ans) {
			out.print(x + 1 + " ");
		}
	}

	private void dfs2(int t, ArrayList<Edge>[] e, boolean[] was, int[] longest,
			int[] goodLongest, int from, int curLongest) {
		if (was[t])
			return;
		was[t] = true;
		goodLongest[t] = Math.max(curLongest, longest[t]);
		int firstMax = -1;
		int secondMax = -1;
		for (Edge ee : e[t]) {
			if (ee.to == from)
				continue;
			if (longest[ee.to] + ee.cost > firstMax) {
				secondMax = firstMax;
				firstMax = longest[ee.to] + ee.cost;
				continue;
			}
			if (longest[ee.to] + ee.cost > secondMax) {
				secondMax = longest[ee.to] + ee.cost;
			}
		}
		for (Edge ee : e[t]) {
			if (ee.to == from)
				continue;
			int curDepth = firstMax;
			if (longest[ee.to] + ee.cost == firstMax)
				curDepth = secondMax;
			if (curLongest > curDepth)
				curDepth = curLongest;
			dfs2(ee.to, e, was, longest, goodLongest, t, curDepth + ee.cost);
		}
	}

	private int dfs(int t, ArrayList<Edge>[] e, boolean[] was, int[] longest, int from) {
		if (was[t])
			return -5;
		was[t] = true;
		int d = 0;
		for (Edge ee : e[t]) {
			if (ee.to == from)
				continue;
			d = Math.max(dfs(ee.to, e, was, longest, t) + ee.cost, d);
		}
		longest[t] = d;
		return d;
	}

	private long dfs3(int t, boolean[] was, long i, ArrayList<Edge>[] e) {
		if (was[t])
			return 0;
		was[t] = true;
		long res = 0;
		for (Edge ee : e[t]) {
			res = res + dfs3(ee.to, was, i + ee.cost, e);
		}
		res = res + i * i;
		return res;
	}

	public void run() {
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);

			br = new BufferedReader(new FileReader("bfs.in"));
			out = new PrintWriter("bfs.out");

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

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