#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
vector<vector<int>> dis(2, vector<int>(100010));
vector<vector<int>> to(100010);
void memo_depth(int a, int b, int d, int p = -1) {
  dis[b][a] = d;
  for (auto r : to[a]) {
    if (r == p) continue;
    memo_depth(r, b, d + 1, a);
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  memo_depth(u, 0, 0);
  memo_depth(v, 1, 0);
  if (to[u].size() == 1) {
    for (auto p : to[v]) {
      if (p == to[u][0]) {
        cout << 1 << endl;
        return 0;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (dis[1][i] > dis[0][i]) {
      if ((dis[1][i] - dis[0][i]) % 2 == 0)
        ans = max(dis[1][i], ans);
      else
        ans = max(dis[1][i] - 1, ans);
    }
  }
  cout << ans << endl;
  return 0;
}
