#include <bits/stdc++.h>
using namespace std;
vector<int> tree[(int)(1e5 + 10)];
vector<int> done((int)(1e5 + 10));
vector<int> pos;
long long ans = 0;
void dfs(int r, int parent) {
  for (int to : tree[r]) {
    if (to == parent) continue;
    dfs(to, r);
    if (done[to] == 0) {
      ans += 2;
      done[to] = 1;
      done[r] = 1;
      swap(pos[to], pos[r]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  pos = vector<int>(n + 1);
  for (int i = 1; i <= n; i++) pos[i] = i;
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  dfs(1, -1);
  if (done[1] == 0) {
    ans += 2;
    swap(pos[1], pos[tree[1][0]]);
  }
  cout << ans << "\n";
  for (int i = 1; i <= n; i++) cout << pos[i] << " ";
}
