#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int ans = 0;
void dfs(vector<vector<int>>& g, int a[], vector<bool>& swapped, int cur,
         int par) {
  for (int e : g[cur]) {
    if (e != par) dfs(g, a, swapped, e, cur);
  }
  if (!swapped[cur]) {
    if (cur == 1) {
      par = g[cur][0];
    }
    swap(a[cur], a[par]);
    swapped[cur] = true;
    swapped[par] = true;
    ans += 2;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> g(n + 1);
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  int a[n + 1];
  iota(a, a + n + 1, 0);
  vector<bool> swapped(n + 1);
  dfs(g, a, swapped, 1, 0);
  cout << ans << "\n";
  for (int i = 1; i < n + 1; i++) cout << a[i] << " ";
  cout << "\n";
}
