#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long MAXN = 100010;
int N, a, b;
int A[MAXN];
queue<int> Q;
set<int> S[MAXN];
int fl = -1;
int O[MAXN];
int main() {
  cin >> N;
  for (int i = 1; i < N; ++i) {
    cin >> a >> b;
    O[a] = b;
    O[b] = a;
    S[a].insert(b);
    S[b].insert(a);
  }
  for (int i = 1; i <= N; ++i) {
    A[i] = i;
    if ((long long)S[i].size() == 1) Q.push(i);
  }
  int ans = 0;
  while ((long long)Q.size()) {
    int x = Q.front();
    Q.pop();
    if ((long long)S[x].size() == 0 && A[x] == x) {
      swap(A[x], A[O[x]]);
      ans += 2;
      break;
    }
    int t = *S[x].begin();
    if (A[x] == x) {
      ans += 2;
      swap(A[x], A[t]);
    }
    S[t].erase(x);
    S[x].erase(t);
    if ((long long)S[t].size() == 1) Q.push(t);
  }
  cout << ans << '\n';
  for (int i = 1; i <= N; ++i) {
    assert(A[i] != i);
    cout << A[i] << ' ';
  }
  cout << '\n';
}
