#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000009;
long long MOD = 1000000007;
vector<long long> adj[100010];
bool visited[100010];
long long dist[100010];
long long dist2[100010];
void solve() {
  long long n;
  cin >> n;
  long long u, v;
  cin >> u >> v;
  u--;
  v--;
  for (long long i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].emplace_back(b);
    adj[b].emplace_back(a);
  }
  for (long long i = 0; i < 100010; i++) {
    visited[i] = false;
    dist[i] = 0;
  }
  stack<long long> st;
  st.push(v);
  visited[v] = true;
  while (!st.empty()) {
    long long x = st.top();
    st.pop();
    for (auto e : adj[x]) {
      if (visited[e] == true) continue;
      dist[e] = dist[x] + 1;
      st.push(e);
      visited[e] = true;
    }
  }
  for (long long i = 0; i < 100010; i++) {
    visited[i] = false;
    dist2[i] = 0;
  }
  stack<long long> st2;
  st2.push(u);
  visited[u] = true;
  while (!st2.empty()) {
    long long x = st2.top();
    st2.pop();
    for (auto e : adj[x]) {
      if (visited[e] == true) continue;
      dist2[e] = dist2[x] + 1;
      st2.push(e);
      visited[e] = true;
    }
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    if (dist[i] > dist2[i]) ans = max(ans, dist2[i] - 1);
  }
  if (ans != 0)
    cout << ans << endl;
  else
    cout << (dist[u]) / 2 << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
