#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
vector<int> adj[100005];
int n, u, v, ans;
int dep[100005];
bool checkU(int from, int fa) {
  if (from == u) return 1;
  bool ans = 0;
  for (auto i : adj[from])
    if (i != fa) ans |= checkU(i, from);
  return ans;
}
void findDep(int from, int fa) {
  dep[from] = dep[fa] + 1;
  if (dep[from] > ans) ans = dep[from];
  for (auto i : adj[from])
    if (i != fa) findDep(i, from);
}
int main() {
  while (~scanf("%d%d%d", &n, &u, &v)) {
    for (int i = 1; i <= n; i++) adj[i].clear();
    for (int i = 1; i <= n; i++) dep[i] = 0;
    for (int i = 0; i < n - 1; i++) {
      int(x), (y);
      scanf("%d %d", &(x), &(y));
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    int child;
    for (auto i : adj[v])
      if (checkU(i, v)) {
        child = i;
        break;
      }
    ans = 0;
    findDep(child, v);
    assert(ans > 0);
    printf("%d\n", ans - 1);
  }
}
