#include <bits/stdc++.h>
using namespace std;
using vint = vector<long long>;
using pint = pair<long long, long long>;
using vpint = vector<pint>;
template <typename A, typename B>
inline void chmin(A& a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A& a, B b) {
  if (a < b) a = b;
}
template <class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>& p) {
  ost << "{" << p.first << "," << p.second << "}";
  return ost;
}
template <class T>
ostream& operator<<(ostream& ost, const vector<T>& v) {
  ost << "{";
  for (long long i = 0; i < v.size(); i++) {
    if (i) ost << ",";
    ost << v[i];
  }
  ost << "}";
  return ost;
}
long long N, u, v;
vint G[111111];
void dfs(long long v, long long p, long long d, vint& dist) {
  dist[v] = d;
  for (auto u : G[v]) {
    if (u == p) continue;
    dfs(u, v, d + 1, dist);
  }
}
signed main() {
  scanf("%lld%lld%lld", &N, &u, &v);
  u--;
  v--;
  for (long long i = 0; i < (N - 1); i++) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vint distU(N), distV(N);
  dfs(u, -1, 0, distU);
  dfs(v, -1, 0, distV);
  long long ma = 0;
  for (long long i = 0; i < (N); i++) {
    if (distU[i] > distV[i]) continue;
    long long tmp = (distV[i] - distU[i]) / 2;
    chmax(ma, distU[i] + tmp);
  }
  cout << ma << endl;
  return 0;
}
