#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
int bfs(const vvi &tree, vi &dist, int N, int start) {
  dist.resize(N);
  fill(begin(dist), end(dist), -1);
  queue<int> next;
  dist[start] = 0;
  next.push(start);
  int longest;
  while (!next.empty()) {
    int cp = next.front();
    next.pop();
    for (int node : tree[cp]) {
      if (dist[node] < 0) {
        dist[node] = dist[cp] + 1;
        next.push(node);
        longest = node;
      }
    }
  }
  return longest;
}
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  vvi tree(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    tree[a - 1].push_back(b - 1);
    tree[b - 1].push_back(a - 1);
  }
  --u;
  --v;
  vi distance;
  int longest_virt = bfs(tree, distance, N, v);
  bfs(tree, distance, N, longest_virt);
  int ans = distance[u] + (distance[v] - distance[u]) / 2;
  cout << ans << endl;
  return 0;
}
