#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005], c[100005];
vector<long long> d[100005];
void dfs(long long v, long long s) {
  a[v] = a[s] + 1;
  b[v] = 1;
  c[v] = s;
  for (auto x : d[v]) {
    if (x == s) continue;
    dfs(x, s);
    b[v] = max(b[v], b[x] + 1);
  }
}
int32_t main() {
  long long n, u, v;
  cin >> n >> u >> v;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    d[x].push_back(y);
    d[y].push_back(x);
  }
  dfs(v, 0);
  long long ans = -1;
  long long dis = a[u] - a[v];
  dis = (dis - 1) / 2;
  while (dis--) {
    u = c[u];
  }
  if (d[u].size() == 1)
    ans = a[u] - 2;
  else
    ans = b[u] + a[u] - 3;
  cout << ans << endl;
}
