#include <bits/stdc++.h>
using namespace std;
int n, u, v, a, b;
vector<vector<int> > e;
vector<int> takahashi, aoki;
void distance_from_aoki(int c, int p) {
  aoki.at(c) = aoki.at(p) + 1;
  for (auto i = e.at(c).begin(); i != e.at(c).end(); ++i)
    if (*i != p) distance_from_aoki(*i, c);
}
void distance_from_takahashi(int c, int p) {
  takahashi.at(c) = takahashi.at(p) + 1;
  if (takahashi.at(c) >= aoki.at(c)) takahashi.at(c) = 1000000000;
  for (auto i = e.at(c).begin(); i != e.at(c).end(); ++i)
    if (*i != p) distance_from_takahashi(*i, c);
}
int main() {
  ios::sync_with_stdio(false);
  int ans = 0;
  cin >> n >> u >> v;
  e.resize(n + 1);
  takahashi.resize(n + 1);
  aoki.resize(n + 1);
  takahashi.at(0) = -1;
  aoki.at(0) = -1;
  for (int i = 1; i < n; ++i) {
    cin >> a >> b;
    e.at(a).push_back(b), e.at(b).push_back(a);
  }
  distance_from_aoki(v, 0);
  distance_from_takahashi(u, 0);
  for (int i = 1; i <= n; ++i)
    if (aoki.at(i) >= takahashi.at(i))
      ans = max(ans, takahashi.at(i) + (aoki.at(i) - takahashi.at(i)) / 2);
  cout << ans << endl;
  return 0;
}
