#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void maxa(T& a, T b) {
  a = max(a, b);
}
template <typename T>
inline void mina(T& a, T b) {
  a = min(a, b);
}
const int mxN = 1e5 + 5, mod = 1e9 + 7;
int n, a, b, go[mxN];
vector<int> graph[mxN];
vector<pair<int, int> > prs;
long long ans = 0;
void dfs(int at, int p) {
  for (int& i : graph[at]) {
    if (i == p) continue;
    dfs(i, at);
  }
  if (go[at] == at) {
    ans += 2;
    if (p == -1)
      swap(go[at], go[graph[at][0]]);
    else
      swap(go[at], go[p]);
  }
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) go[i] = i;
  dfs(1, -1);
  cout << ans << "\n";
  for (int i = 1; i <= n; i++) cout << go[i] << " ";
}
