#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll LINF = 1LL << 62;
const int INF = 1e9 + 7;
vector<vector<ll>> tree(100010);
ll dist[100010];
ll dfs(ll crr, ll pr, ll cr_dis) {
  if (tree[crr].size() == 1) {
    if (cr_dis < dist[crr]) return cr_dis;
    dist[crr] = cr_dis;
    return -1;
  }
  ll ans = 0;
  for (ll chd : tree[crr])
    if (chd != pr) {
      ans = max(ans, dfs(chd, crr, cr_dis + 1));
    }
  return ans;
}
int main() {
  ll n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  for (ll i = 0; i < n - 1; ++i) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  for (ll i = 0; i < 100010; ++i) dist[i] = -1;
  for (ll chd : tree[v]) dfs(chd, v, 1);
  ll ans = 0;
  for (ll chd : tree[u]) ans = max(ans, dfs(chd, u, 1));
  cout << ans << endl;
}
