#include <bits/stdc++.h>

using namespace std;

struct S {
  int d[2];
  vector<int> to;
};

vector<S> V;

void dfs(int v, int prev, int t, int d) {
  V[v].d[t] = d++;
  for (auto to : V[v].to)
    if (to != prev) dfs(to, v, t, d);
};

int main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  V.resize(N);
  for (int i = N - 1; i--;) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    V[a].to.push_back(b);
    V[b].to.push_back(a);
  }
  dfs(u, -1, 0, 0);
  dfs(v, -1, 1, 0);
  int ans = 0;
  for (auto& v : V)
    if (v.d[1] > v.d[0]) ans = max(ans, v.d[1]);
  cout << ans - 1 << endl;
  return 0;
}
