#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, u, v;
  cin >> n >> u >> v;
  vector<vector<long long>> G(n);
  for (int i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<long long> dist(n + 1, -1);
  long long max = 0;
  dist[v] = 0;
  queue<long long> que;
  que.push(v);
  while (!que.empty()) {
    int a = que.front();
    que.pop();
    for (int i : G[v]) {
      if (dist[i] != -1) continue;
      dist[i] = dist[a] + 1;
      if (dist[i] > max) {
        dist[i] = max;
      }
      que.push(i);
    }
  }
  cout << max / 2;
}
