#include <bits/stdc++.h>
using namespace std;
int n, a[10001][10001];
long long f[100001], x, y;
void dfs(int i) {
  for (int j = 1; j <= n; j++) {
    if (a[i][j] && f[j] > f[i] + 1) {
      f[j] = f[i] + 1;
      dfs(j);
    }
  }
  return;
}
int main() {
  int q, w;
  cin >> n >> x >> y;
  for (int i = 1; i < n; i++) {
    cin >> q >> w;
    a[q][w] = a[w][q] = 1;
    f[i] = 99999999;
  }
  f[n] = 99999999;
  f[x] = 0;
  dfs(x);
  if (f[y] % 2 == 0)
    cout << f[y] / 2;
  else
    cout << f[y] / 2 + 1;
  return 0;
}
