#include <bits/stdc++.h>
using namespace std;
const int N = 1e5;
int a[1 + N];
int h[1 + N];
vector<int> gr[1 + N];
int best[1 + N];
int fat[1 + N];
int bestson[1 + N];
void pre_dfs(int node, int f) {
  h[node] = h[f] + 1;
  fat[node] = f;
  best[node] = 1;
  bestson[node] = 0;
  for (auto son : gr[node])
    if (son != f) {
      pre_dfs(son, node);
      if (best[node] < best[son] + 1) {
        bestson[node] = son;
        best[node] = best[son] + 1;
      }
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  pre_dfs(b, 0);
  int node_a = a;
  int steps = 0;
  while (h[b] + steps + 1 < h[a] - steps - 1) {
    steps++;
    node_a = fat[node_a];
  }
  int node_b;
  if ((h[b] - h[a]) % 2) {
    node_b = fat[node_a];
  } else {
    node_b = fat[fat[node_a]];
  }
  if (node_b == 0) {
    cout << 0 << "\n";
  }
  int ans = steps;
  steps = 0;
  while (node_a != node_b) {
    if (steps % 2) {
      node_b = bestson[node_b];
      ans++;
    } else {
      if (bestson[node_a] == 0)
        node_a = fat[node_a];
      else
        node_a = bestson[node_a];
    }
    steps++;
    if (steps > N * 100) {
      cout << 0;
      return 0;
    }
  }
  cout << ans << "\n";
  return 0;
}
