#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> e(1e5);
vector<long long> aoki(1e5, 1e9), taka(1e5, 0);
vector<bool> flag(1e5, false);
void aoki_bfs(long long node, long long cnt) {
  aoki[node] = cnt;
  for (long long i = 0; i < e[node].size(); i++) {
    if (flag[e[node][i]] == false) {
      flag[e[node][i]] = true;
      aoki_bfs(e[node][i], cnt + 1);
    }
  }
}
void taka_bfs(long long node, long long cnt) {
  taka[node] = cnt;
  for (long long i = 0; i < e[node].size(); i++) {
    if (flag[e[node][i]] == false) {
      flag[e[node][i]] = true;
      taka_bfs(e[node][i], cnt + 1);
    }
  }
}
signed main(void) {
  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--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  for (long long i = 0; i < n; i++) flag[i] = false;
  flag[u] = true;
  taka_bfs(u, 0);
  for (long long i = 0; i < n; i++) flag[i] = false;
  flag[v] = true;
  aoki_bfs(v, 0);
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (taka[i] < aoki[i]) {
      long long tmp = aoki[i] - 1;
      if (ans < tmp) ans = tmp;
    }
  }
  cout << ans << endl;
  return 0;
}
