#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int N = 1e5 + 5;
int n, res, p[N];
set<int> edges[N], leaf;
vector<int> tmp;
bool visited[N];
void step(int id) {
  leaf.erase(id);
  visited[id] = 1;
  res += 2;
  int v = *edges[id].begin();
  swap(p[id], p[v]);
  if (!visited[v]) tmp.push_back(v), visited[v] = 1;
  edges[id].clear();
}
void del(int id) {
  leaf.erase(id);
  for (int v : edges[id]) {
    if (!visited[v] && edges[v].size() == 1) {
      step(v);
    } else if (!visited[v]) {
      edges[v].erase(id);
      if (edges[v].size() == 1) {
        leaf.insert(v);
      }
    }
  }
  edges[id].clear();
  tmp.pop_back();
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  iota(p, p + N, 0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    edges[--u].insert(--v);
    edges[v].insert(u);
  }
  tmp.reserve(n);
  for (int i = 0; i < n; i++) {
    if (edges[i].size() == 1) leaf.insert(i);
  }
  while (!leaf.empty()) {
    step(*leaf.begin());
    while (!tmp.empty()) {
      del(tmp.back());
    }
  }
  cout << res << '\n';
  for (int i = 0; i < n; i++) {
    cout << p[i] + 1 << ' ';
  }
  cout << '\n';
}
