#include <bits/stdc++.h>
using namespace std;
int N, u, v, a, b, dep[100000] = {0}, depA[100000] = {0}, maxL = 0, aokiDe;
vector<int> vec[100000];
vector<bool> use[100000];
bool deep(int s, int num) {
  bool exist = false;
  if (dep[s] == 0) {
    dep[s] = num;
    if (v == s) return true;
    for (int i = 0; i < vec[s].size(); i++) {
      use[s][i] = deep(vec[s][i], num + 1);
      exist |= use[s][i];
    }
    return exist;
  }
  return false;
}
void deepAns(int s, int num) {
  if (depA[s] == 0) {
    depA[s] = num;
    maxL = max(maxL, num);
    for (int i = 0; i < vec[s].size(); i++) {
      if ((!use[s][i]) ||
          (use[s][i] && dep[vec[s][i]] - 1 < aokiDe - dep[vec[s][i]]))
        deepAns(vec[s][i], num + 1);
    }
  }
}
int main() {
  bool vast;
  cin >> N >> u >> v;
  u -= 1;
  v -= 1;
  for (int i = 0; i < N - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    vec[a].push_back(b);
    use[a].push_back(true);
    vec[b].push_back(a);
    use[b].push_back(true);
  }
  vast = deep(u, 1);
  aokiDe = dep[v];
  maxL = 0;
  deepAns(u, 1);
  cout << maxL - 1;
  return 0;
}
