#include <bits/stdc++.h>
using namespace std;
vector<int> tree[100001];
int L[100001];
void DFS(int past, int now, int level) {
  L[now] = level;
  for (int i = 0; i < tree[now].size(); i++) {
    if (past != -1) {
      if (tree[now][i] == past) {
        continue;
      }
    }
    DFS(now, tree[now][i], level + 1);
  }
}
int DFS_2(int past, int now, int level, int BannedL) {
  if (L[now] <= BannedL) {
    return -1;
  }
  int M = 0;
  for (int i = 0; i < tree[now].size(); i++) {
    if (past != -1) {
      if (tree[now][i] == past) {
        continue;
      }
    }
    M = max(M, DFS_2(now, tree[now][i], level + 1, BannedL));
  }
  return max(M, level);
}
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B;
    tree[A].push_back(B);
    tree[B].push_back(A);
  }
  DFS(-1, v, 0);
  int ban = L[u] / 2;
  int result = DFS_2(-1, u, 0, ban);
  if (result == 0 && L[u] == 2) {
    result = 1;
  }
  cout << result << endl;
  return 0;
}
