#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
vector<int> e[N];
int dep[N], n, s, t;
void dfs(int u, int f) {
  for (auto v : e[u])
    if (v != f) dfs(v, u), dep[u] = max(dep[u], dep[v]);
  dep[u]++;
}
int main() {
  scanf("%d%d%d", &n, &s, &t);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(t, 0);
  t = dep[t];
  int ans = 0;
  while (1) {
    int k = -1;
    for (auto v : e[s])
      if (k == -1 || dep[v] < dep[k]) k = v;
    s = k;
    if (dep[s] == t) break;
    t--, ans++;
    if (dep[s] == t) break;
  }
  printf("%d\n", ans);
  return 0;
}
