#include <bits/stdc++.h>
using namespace std;
long long exp(long long x, long long y, long long p) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % p) % p;
    x = (x * x) % p;
    y /= 2;
  }
  return res;
}
long long expm(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % ((long long)1e9 + 7)) % ((long long)1e9 + 7);
    x = (x * x) % ((long long)1e9 + 7);
    y /= 2;
  }
  return res;
}
vector<long long> adj[((long long)1e5 + 5)];
long long du[((long long)1e5 + 5)], dv[((long long)1e5 + 5)];
void dfs(long long u, long long par, long long dis[]) {
  for (auto v : adj[u]) {
    if (v == par) continue;
    dis[u] = dis[v] + 1;
    dfs(v, u, dis);
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  {
    long long n, u, v;
    cin >> n >> u >> v;
    u--;
    v--;
    for (long long i = 0; i < n - 1; i++) {
      long long x, y;
      cin >> x >> y;
      x--;
      y--;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    dfs(v, -1, dv);
    dfs(u, -1, du);
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      ans = max(ans, du[i] - dv[i]);
    }
    cout << ans << "\n";
  }
  return 0;
}
