#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << H;
  debug_out(T...);
}
const long long MAXN = 1e5 + 10;
long long n, u, v, a, b, mx, distv[MAXN], distu[MAXN];
vector<long long> adj[MAXN];
void dfs(long long u, long long p, long long dis[MAXN]) {
  for (auto v : adj[u])
    if (v != p) dis[v] = dis[u] + 1, dfs(v, u, dis);
  return;
}
int32_t main() {
  cin >> n >> u >> v;
  for (long long i = 0; i < n - 1; i++)
    cin >> a >> b, adj[a].push_back(b), adj[b].push_back(a);
  dfs(v, 0, distv), dfs(u, 0, distu);
  for (long long i = 1; i <= n; i++)
    if (distv[i] <= distu[i]) mx = max(mx, distu[i] - 1);
  return cout << mx << '\n', 0;
}
