#include <bits/stdc++.h>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
  std::fill((T*)array, (T*)(array + N), val);
}
pair<long long, long long> Dir[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
struct Edge {
  int from, to;
  long long w;
  bool operator<(const Edge& rhs) const {
    return make_pair((w), (make_pair((from), (to)))) <
           make_pair((rhs.w), (make_pair((rhs.from), (rhs.to))));
  }
};
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long factorial(long long n) {
  long long ret = 1;
  for (int i = (1); (n + 1) > i; i++) ret = (ret * i) % 1000000007LL;
  return ret;
}
long long mod_pow(long long x, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}
long long divmod(long long a, long long b, long long m) {
  return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
long long ncr(long long n, long long r) {
  return divmod(factorial(n),
                (factorial(r) * (factorial(n - r))) % 1000000007LL,
                1000000007LL);
}
signed main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  vector<vector<Edge>> g(n);
  for (int i = (0); (n - 1) > i; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back({a, b});
    g[b].push_back({b, a});
  }
  vector<int> depth(n), Maxd(n), par(n);
  function<int(int, int)> dfs = [&](int c, int p) {
    par[c] = p;
    depth[c] = depth[p] + 1;
    int Max = depth[c];
    for (auto itr : g[c]) {
      if (itr.to != p) Max = max(Max, dfs(itr.to, c));
    }
    return Maxd[c] = Max;
  };
  depth[v] = -2;
  dfs(v, v);
  int cur = u, dist = 0, ans = 0;
  while (1) {
    if (depth[cur] == dist) {
      ans = Maxd[cur];
      break;
    }
    cur = par[cur];
  }
  cout << ans << endl;
  return 0;
}
