#include <bits/stdc++.h>
using namespace std;
class TreeNode {
 public:
  vector<int> children;
  int parent;
};
void create_tree(int src, vector<vector<int>>& adjList,
                 vector<TreeNode>& tree) {
  for (int i = 0; i < adjList[src].size(); i++) {
    if (adjList[src][i] != tree[src].parent) {
      tree[src].children.push_back(adjList[src][i]);
      tree[adjList[src][i]].parent = src;
      create_tree(adjList[src][i], adjList, tree);
    }
  }
}
bool give_path(int u, int v, int curr, vector<int>& path,
               vector<TreeNode>& tree) {
  if (curr == v) {
    path.push_back(v);
    return true;
  }
  if (!tree[curr].children.size()) {
    return false;
  }
  for (int i = 0; i < tree[curr].children.size(); i++) {
    bool out_flag = give_path(u, v, tree[curr].children[i], path, tree);
    if (out_flag) {
      path.push_back(curr);
      return true;
    }
  }
  return false;
}
int longest_path(int st, vector<TreeNode>& tree, int next) {
  if (!tree[st].children.size()) {
    return 0;
  }
  int ans = 1;
  for (int i = 0; i < tree[st].children.size(); i++) {
    if (tree[st].children[i] != next)
      ans = max(ans, ((longest_path(tree[st].children[i], tree, next)) + 1));
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, u, v, x, y;
  cin >> n >> u >> v;
  vector<vector<int>> adjList(n + 1);
  vector<TreeNode> tree(n + 1);
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    adjList[x].push_back(y);
    adjList[y].push_back(x);
    tree[i].parent = -1;
  }
  tree[n].parent = -1;
  if (u == v) {
    cout << 0 << endl;
    return 0;
  }
  create_tree(v, adjList, tree);
  vector<int> path;
  give_path(v, u, v, path, tree);
  for (int i = 0; i < path.size(); i++) {
    cout << path[i] << " ";
  }
  int count = ((path.size()) - 2) / 2;
  cout << ((n - count - 1) +
           ((longest_path(path[count], tree, path[count + 1])) - 1))
       << endl;
  return 0;
}
