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

public class bfs_ats_wa {
    StringTokenizer st;
    PrintWriter out;
    BufferedReader br;

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

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

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

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

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

    public class TreeGraph {
        public class Edge {
            Vertex u;
            long weight;

            public Edge(int num, long w) {
                u = vertexes[num];
                weight = w;
            }
        }

        public class Vertex {
            ArrayList<Edge> e;
            long dist;
            long subDist;
            long sqDist;
            int sub;
            boolean used;

            public Vertex() {
                e = new ArrayList<Edge>();
                dist = 0;
                sqDist = 0;
                subDist = 0;
                sub = 0;
            }
        }

        private final int size;
        private Vertex[] vertexes;
        private long minAns = Long.MAX_VALUE;

        public Vertex getRoot() {
            return vertexes[0];
        }

        public TreeGraph(int n, int e) throws IOException {
            size = n;
            vertexes = new Vertex[size];
            for (int i = 0; i < n; i++) {
                vertexes[i] = new Vertex();
            }
            for (int i = 0; i < e; i++) {
                int u = nextInt() - 1;
                int v = nextInt() - 1;
                long w = nextLong();
                vertexes[u].e.add(new Edge(v, w));
                vertexes[v].e.add(new Edge(u, w));
            }
        }

        public void calcSub(Vertex v, long dist) {
            vertexes[0].dist += dist;
            vertexes[0].sqDist += dist * dist;
            v.sub = 1;
            v.subDist = 0;
            v.used = true;
            for (Edge edge : v.e) {
                if (!edge.u.used) {
                    calcSub(edge.u, dist + edge.weight);
                    v.sub += edge.u.sub;
                    v.subDist += edge.u.subDist + edge.weight;
                }
            }
        }

        public void calcDist(Vertex v) {
            v.used = true;
            for (Edge edge : v.e) {
                if (!edge.u.used) {
                    edge.u.dist = v.dist + (size - 2 * edge.u.sub) * edge.weight;
                    calcDist(edge.u);
                }
            }
        }

        public void calcSqDist(Vertex v) {
            v.used = true;
            minAns = Math.min(minAns, v.sqDist);
            for (Edge edge : v.e) {
                if (!edge.u.used) {
                    edge.u.sqDist = v.sqDist + edge.weight * (edge.u.sub * edge.weight + 2 * edge.u.subDist) -
                            edge.weight * ((size - edge.u.sub) * edge.weight + 2 * (v.dist - edge.u.subDist - edge.u.sub * edge.weight));
                    calcSqDist(edge.u);
                }
            }
        }

        public void printAnswer() throws IOException {
            int ans = 0;
            String candidates = "";
            for (int i = 0; i < size; i++) {
                if (vertexes[i].sqDist == minAns) {
                    ans++;
                    candidates += (i + 1) + " ";
                }
            }
            out.println(ans);
            out.println(candidates);
        }

        private void unuse() {
            for (int i = 0; i < size; i++) {
                vertexes[i].used = false;
            }
        }

    }

    private void solve() throws IOException {
        int n = nextInt();
        TreeGraph g = new TreeGraph(n, n - 1);
        g.unuse();
        g.calcSub(g.getRoot(), 0);
        g.unuse();
        g.calcDist(g.getRoot());
        g.unuse();
        g.calcSqDist(g.getRoot());
        g.printAnswer();
    }

    public void run() {
        try {
            br = new BufferedReader(new FileReader("bfs.in"));
            out = new PrintWriter("bfs.out");

            solve();

            br.close();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}
