#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct edge {
  int to;
  int cost;
};
using P = pair<int, int>;
int V;
vector<edge> G[100000];
vector<edge> G2[100000];
int d[100000];
int d2[100000];
void dijkstra(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d, d + V, 1e+9);
  d[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P 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(P(d[e.to], e.to));
      }
    }
  }
}
void dijkstra2(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d2, d2 + V, 1e+9);
  d2[s] = 0;
  que.push(P(0, s));
  while (!que.empty()) {
    P p = que.top();
    que.pop();
    int v = p.second;
    if (d2[v] < p.first) continue;
    for (int i = 0; i < G2[v].size(); ++i) {
      edge e = G2[v][i];
      if (d2[e.to] > d2[v] + e.cost) {
        d2[e.to] = d2[v] + e.cost;
        que.push(P(d2[e.to], e.to));
      }
    }
  }
}
int main() {
  int taka, ao;
  cin >> V >> taka >> ao;
  taka--;
  ao--;
  for (int i = 0; i < V - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge e = {b, 1};
    edge f = {a, 1};
    G[a].push_back(e);
    G[b].push_back(f);
    edge e2 = {b, 1};
    edge f2 = {a, 1};
    G2[a].push_back(e2);
    G2[b].push_back(f2);
  }
  dijkstra(taka);
  dijkstra2(ao);
  int ans = 0;
  for (int i = 0; i < V; i++) {
    if (d[i] < d2[i]) {
      ans = max(ans, d[i]);
    }
  }
  ans = max(ans, d[ao] / 2);
  cout << ans << "\n";
  return 0;
}
