#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > edges;
vector<int> visited;
vector<int> dist;
void visit(int node, int L) {
  if (visited[node] == 1) {
    return;
  }
  dist[node] = L;
  visited[node] = 1;
  for (int i = 0; i < edges[node].size(); i++) {
    visit(edges[node][i], L + 1);
  }
}
int main(int argc, char** argv) {
  int N;
  int u, v;
  int A, B;
  cin >> N >> u >> v;
  u -= 1;
  v -= 1;
  edges.resize(N, vector<int>());
  visited.resize(N, 0);
  dist.resize(N, 0);
  for (int i = 0; i < N - 1; i++) {
    cin >> A >> B;
    A -= 1;
    B -= 1;
    edges[A].push_back(B);
    edges[B].push_back(A);
  }
  visit(u, 0);
  vector<int> dist1(N, 0);
  for (int i = 0; i < N; i++) {
    dist1[i] = dist[i];
  }
  dist.resize(N, 0);
  visited.resize(N, 0);
  for (int i = 0; i < N; i++) {
    dist[i] = 0;
    visited[i] = 0;
  }
  visit(v, 0);
  vector<int> dist2(N, 0);
  for (int i = 0; i < N; i++) {
    dist2[i] = dist[i];
  }
  int moves = dist1[v] % 2 == 0 ? (dist1[v] / 2) : (dist1[v] + 1) / 2;
  if (dist1[v] == 1) {
    moves = 0;
  }
  int tmp;
  for (int i = 0; i < N; i++) {
    if (i != u && i != v && dist1[i] < dist2[i]) {
      if (dist1[i] % 2 == dist2[i] % 2) {
        tmp = dist2[i];
      } else {
        tmp = dist2[i] - 1;
      }
      moves = max(tmp, moves);
    }
  }
  cout << moves << endl;
}
