#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int u, v;
  cin >> u >> v;
  u--;
  v--;
  vector<int> G[N];
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  queue<pair<int, int> > que;
  que.push({0, v});
  int depth_t;
  bool visited[N];
  fill(visited, visited + N, false);
  visited[v] = true;
  int far;
  int dist;
  while (!que.empty()) {
    auto now = que.front();
    que.pop();
    int vtx = now.second;
    int rank = now.first;
    for (int vx : G[vtx]) {
      if (!visited[vx]) {
        que.push({rank + 1, vx});
        visited[vx] = true;
      }
    }
    if (vtx == u) {
      dist = rank;
    }
    if (que.empty()) {
      depth_t = rank;
      far = vtx;
    }
  }
  queue<pair<int, int> > que2;
  que2.push({0, far});
  int depth_v;
  int depth_u;
  fill(visited, visited + N, false);
  visited[far] = true;
  while (!que2.empty()) {
    auto now = que2.front();
    que2.pop();
    int vtx = now.second;
    int rank = now.first;
    if (vtx == u) {
      depth_v = rank;
    }
    if (vtx == v) {
      depth_u = rank;
    } else {
      for (int vx : G[vtx]) {
        if (!visited[vx]) {
          que2.push({rank + 1, vx});
          visited[vx] = true;
        }
      }
    }
  }
  int ans;
  if (depth_u > depth_v) {
    ans = depth_v;
  } else {
    ans = dist / 2;
  }
  cout << ans << endl;
  return 0;
}
