#include <bits/stdc++.h>
using namespace std;
int N, u, v;
vector<vector<int>> graph(100000);
vector<vector<int>> K(100000);
vector<int> deaph(100000, 0);
void KI(int n, int m) {
  for (int x : graph[n]) {
    if (x != m) {
      K[n].push_back(x);
      deaph[x] = deaph[n] + 1;
      KI(x, n);
    }
  }
  return;
}
int main() {
  cin >> N >> u >> v;
  for (int i = 0; i < (int)(N - 1); ++i) {
    int a, b;
    cin >> a >> b;
    graph[a - 1].push_back(b - 1);
    graph[b - 1].push_back(a - 1);
  }
  --u;
  --v;
  KI(v, v);
  int M = 0;
  for (int i = 0; i < (int)(N); ++i) M = max(M, deaph[i]);
  cout << M - 1 << endl;
  return 0;
}
