#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_a[100010];
ll dist_t[100010];
bool isaoki = true;
void dfs(ll crr, ll pr, ll cr_dis) {
  if (isaoki)
    dist_a[crr] = cr_dis;
  else
    dist_t[crr] = cr_dis;
  for (ll chd : tree[crr])
    if (chd != pr) {
      dfs(chd, crr, cr_dis + 1);
    }
}
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 < n; ++i) dist_a[i] = dist_t[i] = -1;
  dist_a[v] = dist_t[u] = 0;
  dfs(v, v, 0);
  dfs(u, u, 0);
  ll ans = 0;
  for (ll i = 0; i < n; ++i) {
    if (dist_t[i] <= dist_a[i]) ans = max(ans, dist_a[i]);
  }
  cout << ans << endl;
}
