#include <bits/stdc++.h>
using namespace std;
int tansaku(int now, int count, vector<vector<int>> &Ki, vector<bool> &check,
            vector<int> hito) {
  if (check.at(now)) return 0;
  check.at(now) = true;
  hito.at(now) = count;
  for (int i = 0; i < Ki.at(now).size(); i++) {
    tansaku(Ki.at(now).at(i), count + 1, Ki, check, hito);
  }
  return 0;
}
int main() {
  int N, Takahashi, Aoki;
  cin >> N >> Takahashi >> Aoki;
  vector<vector<int>> Ki(N);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    Ki.at(a - 1).emplace_back(b - 1);
    Ki.at(b - 1).emplace_back(a - 1);
  }
  vector<bool> Ao(N, false), Ta(N, false);
  vector<int> A(N), T(N);
  int count = 0;
  tansaku(Takahashi, count, Ki, Ao, A);
  count = 0;
  tansaku(Aoki, count, Ki, Ta, T);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans = max(A.at(i) - T.at(i), 0);
  }
  cout << ans << endl;
}
