#include <bits/stdc++.h>
using namespace std;
int n;
int u, v, x, y;
vector<int> ga[100100];
bool vis[100100];
int dist[2][100100];
queue<int> q;
void BFS(int s, int* dis) {
  memset(dis, 63, sizeof(dis));
  dis[s] = 0;
  q.push(s);
  for (int i = 1; i <= n; i++) vis[i] = false;
  vis[s] = true;
  while (q.size()) {
    s = q.front();
    q.pop();
    for (int i = 0; i < ga[s].size(); i++) {
      int t = ga[s][i];
      if (!vis[t]) {
        dis[t] = dis[s] + 1;
        vis[t] = true;
        q.push(t);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> u >> v;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    ga[x].push_back(y);
    ga[y].push_back(x);
  }
  BFS(u, dist[0]);
  BFS(v, dist[1]);
  int mroad = dist[0][v];
  int tim = 0, cand;
  for (int i = 1; i <= n; i++) {
    if (dist[0][i] == dist[1][i])
      cand = (mroad / 2);
    else if (dist[0][i] > dist[1][i])
      cand = 0;
    else {
      int rem = dist[1][i] - dist[0][i];
      cand = dist[0][i] + rem / 2;
    }
    tim = max(tim, cand);
  }
  cout << tim << endl;
  return 0;
}
