#include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 100000;
int n;
vector<int> adj[MAXN];
int ans[MAXN];
bool alive[MAXN];
int deg[MAXN];
int q[MAXN], qhead, qtail;
int solve() {
  for (int i = (0); i < (n); ++i) ans[i] = i;
  for (int i = (0); i < (n); ++i) deg[i] = ((int)(adj[i]).size());
  for (int i = (0); i < (n); ++i) alive[i] = true;
  for (int i = (0); i < (n); ++i)
    if (deg[i] <= 1) q[qhead++] = i;
  int ret = 0;
  while (qtail < qhead) {
    int at = q[qtail++];
    alive[at] = false;
    int found = -1;
    for (int i = (0); i < (((int)(adj[at]).size())); ++i) {
      int to = adj[at][i];
      if (!alive[to]) continue;
      if (--deg[to] == 1) q[qhead++] = to;
      assert(found == -1);
      found = to;
    }
    if (ans[at] != at) continue;
    if (found != -1) {
      ++ret;
      swap(ans[at], ans[found]);
    } else {
      int any = adj[at][0];
      ++ret;
      swap(ans[at], ans[any]);
    }
  }
  return 2 * ret;
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n - 1); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  printf("%d\n", solve());
  for (int i = (0); i < (n); ++i) {
    if (i != 0) printf(" ");
    printf("%d", ans[i] + 1);
  }
  puts("");
}
int main() {
  run();
  return 0;
}
