#include <bits/stdc++.h>
using namespace std;
int inf = 10000007;
int min2(int a, int b) {
  int ans = a;
  if (ans > b) ans = b;
  return ans;
}
class Ki {
 public:
  bool comp;
  int no;
  int num;
  vector<int> child;
  void pre(int i) {
    comp = true;
    no = i;
    num = child.size();
  }
};
void bfs(vector<int>& dist, vector<Ki> ki, int n, int s) {
  for (long long i = 1; i <= n; ++i) {
    ki[i].pre(i);
  }
  queue<Ki> que;
  que.push(ki[s]);
  dist[s] = 0;
  while (!que.empty()) {
    Ki buf = que.front();
    que.pop();
    int buf_num = buf.no;
    if (ki[buf_num].comp) {
      ki[buf_num].comp = false;
      int chil_num = buf.num;
      for (long long i = 0; i < chil_num; ++i) {
        dist[buf.child[i]] = min2(dist[buf.child[i]], dist[buf.no] + 1);
        que.push(ki[buf.child[i]]);
      }
    }
  }
}
void bfs2(vector<int>& dist, vector<Ki> ki, int n, int s,
          vector<int> const& a) {
  for (long long i = 1; i <= n; ++i) {
    ki[i].pre(i);
  }
  queue<Ki> que;
  que.push(ki[s]);
  dist[s] = 0;
  while (!que.empty()) {
    Ki buf = que.front();
    que.pop();
    int buf_num = buf.no;
    if (ki[buf_num].comp) {
      ki[buf_num].comp = false;
      int chil_num = buf.num;
      if (dist[buf.no] >= a[buf.no]) {
        continue;
      }
      for (long long i = 0; i < chil_num; ++i) {
        dist[buf.child[i]] = min2(dist[buf.child[i]], dist[buf.no] + 1);
        que.push(ki[buf.child[i]]);
      }
    }
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  vector<Ki> ki(n + 1);
  for (long long i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    ki[a].child.push_back(b);
    ki[b].child.push_back(a);
  }
  vector<int> t(n + 1, inf);
  vector<int> a(n + 1, inf);
  bfs(a, ki, n, v);
  bfs2(t, ki, n, u, a);
  int max = 0;
  int ans;
  for (long long i = 1; i <= n; ++i) {
    if (t[i] != inf) {
      if (max < a[i]) {
        if (t[i] % 2 == a[i] % 2) {
          max = t[i];
          ans = a[i];
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
