#include <bits/stdc++.h>
using namespace std;
vector<int> Adj[100005];
int N, u, v, A[100005], B[100005];
int C[100005];
int used[100005];
void ASSIGN(int k, int num) {
  C[k] = num;
  used[k] = 1;
  for (auto y : Adj[k]) {
    if (used[y] == 0) {
      ASSIGN(y, num + 1);
    }
  }
}
int ans;
void REC(int k, int num) {
  if (C[k] <= num) {
    ans = max(ans, C[k]);
    return;
  }
  for (auto y : Adj[k]) {
    REC(y, num + 1);
  }
}
int main(void) {
  cin >> N >> u >> v;
  for (int i = 1; i <= N - 1; i++) {
    cin >> A[i] >> B[i];
    Adj[A[i]].push_back(B[i]);
    Adj[B[i]].push_back(A[i]);
  }
  ASSIGN(v, 0);
  for (int i = 1; i <= N; i++) {
    used[i] = 0;
  }
  REC(u, 0);
  cout << ans << endl;
  return 0;
}
