#include <bits/stdc++.h>
using namespace std;
void tree_search(vector<int>& distance, vector<pair<int, int> > edge,
                 vector<bool>& visited, int node, int current_distance) {
  if (visited[node - 1]) return;
  visited[node - 1] = true;
  distance[node - 1] = current_distance;
  for (int i = 0; i < (int)(visited.size()); i++) {
    int f, s;
    f = edge[i].first, s = edge[i].second;
    if (f == node)
      tree_search(distance, edge, visited, s, current_distance + 1);
    if (s == node)
      tree_search(distance, edge, visited, f, current_distance + 1);
  }
  return;
}
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  vector<int> distance(N, 0);
  vector<pair<int, int> > edge(N - 1);
  vector<vector<int> > next_node(N + 1);
  for (int i = 0; i < (int)(N - 1); i++) {
    int A, B;
    cin >> A >> B;
    edge[i] = make_pair(A, B);
    next_node[A].push_back(B);
    next_node[B].push_back(A);
  }
  vector<bool> visited(N, false);
  tree_search(distance, edge, visited, v, 0);
  auto cmp = [&](const int& a, const int& b) {
    return distance[a] < distance[b];
  };
  for (int i = 1; i < N + 1; i++) {
    sort(next_node[i].begin(), next_node[i].end(), cmp);
  }
  int moved = 0;
  int uflag = 1;
  while (true) {
    if (u == v) break;
    if (uflag) {
      u = next_node[u][0];
    } else {
      int tmp = next_node[v].size();
      v = next_node[v][tmp - 1];
      moved++;
    }
    uflag ^= 1;
  }
  cout << moved << endl;
}
