#include <bits/stdc++.h>
using namespace std;
int n, x, y, t, p[100003], cost[100003], d[100003], udah[100003];
vector<pair<int, int> > adj[100003], temp;
vector<int> ans;
void DFS(int u) {
  for (int i = 0; i < adj[u].size(); i++) {
    int v = adj[u][i].first;
    if (d[v] == -1) {
      d[v] = d[u] + 1;
      cost[v] = cost[u] + adj[u][i].second;
      p[v] = u;
      DFS(v);
    }
  }
}
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d%d", &x, &y, &t);
    adj[x].push_back(make_pair(y, t));
    adj[y].push_back(make_pair(x, t));
  }
  p[1] = -1;
  memset(d, -1, sizeof(d));
  memset(udah, -1, sizeof(udah));
  cost[1] = d[1] = 0;
  udah[1] = 1;
  DFS(1);
  for (int i = 1; i <= n; i++) temp.push_back(make_pair(d[i], i));
  sort(temp.begin(), temp.end());
  for (int i = temp.size() - 1; i >= 0; i--) {
    int u = temp[i].second;
    if (cost[u] - cost[p[u]] == 1 || udah[u] == 1) continue;
    ans.push_back(u);
    while (udah[u] == -1) {
      udah[u] = 1;
      u = p[u];
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i];
    if (i == ans.size() - 1)
      cout << endl;
    else
      cout << " ";
  }
}
