#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long N = 1e5 + 5;
vector<long long> adj[N];
long long n, x, y;
long long solve(long long tak, long long ptak, long long aok, long long paok,
                long long turn) {
  if (tak == aok) {
    return 0;
  }
  if (!turn) {
    long long ans = 0;
    for (long long v : adj[tak]) {
      if (v ^ ptak) ans = max(ans, solve(v, tak, aok, paok, !turn));
    }
    return ans;
  } else {
    long long ans = (long long)1e18 + 5;
    for (long long v : adj[aok]) {
      if (v ^ paok) {
        ans = min(ans, 1 + solve(tak, ptak, v, aok, !turn));
      }
    }
    return ans;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long u, v;
  cin >> n >> u >> v;
  for (long long i = 0; i < n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  cout << solve(u, 0, v, 0, 0) << "\n";
  return 0;
}
