#include <bits/stdc++.h>
#pragma GCC optimization("O3")
using namespace std;
const int N = 100 * 1000 + 5;
int n;
bool ok;
vector<int> v[N];
vector<int> dt(N), da(N);
void dfs(int s, int pr, int d, bool ok) {
  if (ok) {
    da[s] = d;
    for (auto g : v[s]) {
      if (g != pr) dfs(g, s, d + 1, true);
    }
  } else {
    dt[s] = d;
    for (auto g : v[s]) {
      if (g != pr) dfs(g, s, d + 1, false);
    }
  }
}
int main() {
  int t, a, m = 1;
  cin >> n >> t >> a;
  for (int i = 1; i < n; ++i) {
    int n1, n2;
    cin >> n1 >> n2;
    v[n1].push_back(n2);
    v[n2].push_back(n1);
  }
  dfs(a, -1, 0, true);
  dfs(t, -1, 0, false);
  for (int i = 1; i < n + 1; i++) {
    if (dt[i] < da[i]) {
      m = max(m, dt[i]);
    }
  }
  cout << m;
  return 0;
}
