#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 1000000000;
int GCD(int a, int b) { return b ? GCD(b, a % b) : a; }
int N;
vector<vector<int>> G;
void dfs(int v, vector<int> &d) {
  for (auto nv : G[v]) {
    if (d[nv] != INF) {
      continue;
    }
    d[nv] = d[v] + 1;
    dfs(nv, d);
  }
  return;
}
int main(void) {
  int u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<int> du(N, INF), dv(N, INF);
  G.resize(N);
  for (int i = 0; i < N - 1; i++) {
    int s, t;
    cin >> s >> t;
    s--;
    t--;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  du[u] = dv[v] = 0;
  dfs(u, du);
  dfs(v, dv);
  int maxd = -1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (du[i] < dv[i] && maxd < du[i]) {
      maxd = du[i];
      ans = dv[i] - 1;
    }
  }
  cout << ans << endl;
}
