#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long pow(long long x, long long y) {
  long long ret = 1, tmp = x;
  while (y) {
    if (y % 2) ret = ret * tmp % mod;
    tmp = tmp * tmp % mod;
    y /= 2;
  }
  return ret;
}
long long inverse(long long x) { return pow(x, mod - 2); }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);
  long long N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<vector<long long> > G(N);
  for (int i = (0); i < (N - 1); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<long long> dist_t(N, -1), dist_a(N, -1);
  dist_t[u] = 0;
  dist_a[v] = 0;
  {
    queue<long long> q;
    q.push(u);
    while (q.size()) {
      long long fr = q.front();
      q.pop();
      for (long long to : G[fr]) {
        if (dist_t[to] == -1) {
          dist_t[to] = dist_t[fr] + 1;
          q.push(to);
        }
      }
    }
  }
  {
    queue<long long> q;
    q.push(v);
    while (q.size()) {
      long long fr = q.front();
      q.pop();
      for (long long to : G[fr]) {
        if (dist_a[to] == -1) {
          dist_a[to] = dist_a[fr] + 1;
          q.push(to);
        }
      }
    }
  };
  ;
  long long x = -1, y = -1;
  for (int i = (0); i < (N); i++) {
    if (dist_t[i] < dist_a[i]) {
      if (y < dist_a[i]) {
        x = dist_t[i];
        y = dist_a[i];
      }
    }
  };
  ;
  long long ans = x;
  y -= x;
  bool f = true;
  while (1) {
    if (f)
      y--;
    else
      y++;
    if (y == 0) {
      cout << ans << endl;
      return 0;
    }
    y--;
    ans++;
    if (y == 0) {
      cout << ans << endl;
      return 0;
    }
  }
}
