#include <bits/stdc++.h>
using namespace std;
void __dbg() { cout << endl; }
template <typename Arg, typename... Args>
void __dbg(Arg A, Args... B) {
  cout << " " << A;
  __dbg(B...);
}
const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9 + 7;
const int maxN = 1e6 + 2;
int main() {
  int n;
  scanf("%d", &n);
  set<int> adj[n + 1];
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    adj[u].insert(v);
    adj[v].insert(u);
  }
  int ans = 0;
  queue<int> q;
  vector<int> res(n + 1);
  for (int i = 1; i < n + 1; i++) {
    res[i] = i;
    if ((int)adj[i].size() == 1) q.push(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    int p = *adj[u].begin();
    int curr = p;
    for (int it : adj[p]) {
      adj[it].erase(p);
      if ((int)adj[it].size() == 1) {
        q.push(it);
      } else if (adj[it].empty()) {
        res[it] = curr;
        res[p] = it;
        curr = it;
        ans += 2;
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 1; i < n + 1; i++) printf("%d ", res[i]);
  return 0;
}
