#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n;
int val[maxn], ans[maxn];
vector<int> edge[maxn];
int f[maxn];
int deg[maxn];
queue<int> q;
void dfs(int u, int fa) {
  f[u] = fa;
  for (int i = 0; i < ((int(edge[u].size()))); i++) {
    int v = edge[u][i];
    if (v == fa) continue;
    deg[u]++;
    dfs(v, u);
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i < (n); i++) {
    int u, v;
    cin >> u >> v;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = 1; i < (n + 1); i++) {
    if (deg[i] == 0) q.push(i);
    val[i] = i;
  }
  int res = 0;
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    if (val[cur] == cur) {
      if (cur == 1)
        swap(val[1], val[edge[1][0]]);
      else
        swap(val[cur], val[f[cur]]);
      res += 2;
    }
    deg[f[cur]]--;
    if (deg[f[cur]] == 0) q.push(f[cur]);
  }
  for (int i = 1; i < (n + 1); i++) ans[val[i]] = i;
  cout << res << endl;
  for (int i = 1; i < (n + 1); i++) cout << ans[i] << " ";
  return 0;
}
