#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
struct edge {
  ll to, cost;
};
const int MAX_V = 100000;
const ll INF = 1LL << 60;
int V;
vector<edge> G[MAX_V];
ll d[MAX_V];
void dijkstra(ll s) {
  priority_queue<pair<ll, ll>, vector<pair<ll, ll> >, greater<pair<ll, ll> > >
      que;
  fill(d, d + V, INF);
  d[s] = 0;
  que.push(pair<ll, ll>(0, s));
  while (!que.empty()) {
    pair<ll, ll> p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(pair<ll, ll>(d[e.to], e.to));
      }
    }
  }
}
int main() {
  int u, v, A, B;
  cin >> V >> u >> v;
  u--;
  v--;
  for (int i = 0; i < V - 1; i++) {
    cin >> A >> B;
    A--;
    B--;
    G[A].push_back({B, 1});
    G[B].push_back({A, 1});
  }
  dijkstra(u);
  vector<int> du(V);
  for (int i = 0; i < V; i++) du[i] = d[i];
  dijkstra(v);
  vector<int> dv(V);
  for (int i = 0; i < V; i++) dv[i] = d[i];
  int maxdu = -1, maxu;
  for (int i = 0; i < V; i++) {
    if (dv[i] <= du[i]) continue;
    if (du[i] > maxdu) {
      maxdu = du[i];
      maxu = i;
    }
  }
  cout << dv[maxu] - 1 << "\n";
}
