#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const long long N = 105000;
const long long mod = 1e9 + 7;
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
vector<int> adj[N];
int alt[N];
void dfs(int u, int p) {
  for (auto x : adj[u]) {
    if (x == p) continue;
    dfs(x, u);
    alt[u] = max(alt[u], alt[x] + 1);
  }
}
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(y, -1);
  int h = alt[x];
  int hm = alt[y];
  cout << hm - 1 << endl;
  return 0;
}
