#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(time(0));
const long long maxn = 1e5 + 50;
vector<long long> r[maxn];
long long ans = 0;
void dfs(long long v, long long p = -1, long long c = 0) {
  ans = max(c, ans);
  for (auto &u : r[v]) {
    if (u != p) dfs(u, v, c + 1);
  }
}
void solve() {
  long long n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (long long i = 0; i < n - 1; ++i) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    r[a].push_back(b);
    r[b].push_back(a);
  }
  dfs(v);
  cout << ans - 1 << endl;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
