#include <bits/stdc++.h>
using namespace std;
const long long int INF = 999999999999999;
const long long int MOD = 1000000007;
long long int a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans = 0;
vector<long long int> gragh[100101], visited(100002, 0), ko(100002, 0),
    par(100002, 0);
long long int dfs(long long int x) {
  visited[x] = 1;
  long long int st = -1, sq, sr = -1;
  for (long long int i : gragh[x]) {
    if (visited[i] == 0) {
      par[i] = x;
      sq = dfs(i);
      if (st < sq) {
        st = sq;
        sr = i;
      }
    }
  }
  ko[x] = sr;
  if (sr == -1) return 0;
  return st + 1;
}
long long int solve(void) {
  a = x;
  b = y;
  ans = 0;
  while (1) {
    if (par[a] != b)
      a = par[a];
    else if (ko[a] != -1) {
      a = ko[a];
    } else {
      return ans;
    }
    ans++;
    b = ko[b];
    if (a == b) return ans;
  }
}
int main() {
  cin >> n >> x >> y;
  for (long long int i = 0; i < long long int(n - 1); i++) {
    cin >> a >> b;
    gragh[a].push_back(b);
    gragh[b].push_back(a);
  }
  dfs(y);
  cout << solve() << endl;
}
