#include <bits/stdc++.h>
using namespace std;
vector<long long> ch[100010];
long long n, a, b, deep[100010], lim;
void dep(long long now, long long cnt) {
  deep[now] = cnt;
  for (long long i = 0; i < ch[now].size(); i++) {
    long long nex = ch[now][i];
    if (deep[nex] != -1) {
      continue;
    }
    dep(nex, cnt + 1);
  }
}
long long limnow;
void up(long long now, long long cnt) {
  if (lim == cnt) {
    limnow = now;
    return;
  }
  for (long long i = 0; i < ch[now].size(); i++) {
    long long nex = ch[now][i];
    if (deep[nex] < now) {
      up(nex, cnt + 1);
    }
  }
}
long long ans = 0;
void see(long long now, long long cnt) {
  ans = max(ans, cnt);
  for (long long i = 0; i < ch[now].size(); i++) {
    long long nex = ch[now][i];
    if (deep[nex] > cnt) {
      see(nex, cnt + 1);
    }
  }
}
int main() {
  cin >> n >> a >> b;
  a--;
  b--;
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    ch[x].push_back(y);
    ch[y].push_back(x);
  }
  for (long long i = 0; i < n; i++) {
    deep[i] = -1;
  }
  dep(b, 0);
  lim = deep[a] / 2 + 1;
  up(a, 1);
  see(limnow, deep[limnow]);
  if (ans == 1) {
    cout << 0;
    return 0;
  }
  cout << ans - 1;
  return 0;
}
