#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long from, to, cost;
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long N, INF = 1e9 + 7, u, v, a, b, ans = 0;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<edge> es(2 * N - 2);
  vector<long long> d(N, 0);
  for (long long(i) = 0; i < (N - 1); ++(i)) {
    cin >> a >> b;
    a--;
    b--;
    es[2 * i] = edge{a, b, 1};
    es[2 * i + 1] = edge{b, a, 1};
  }
  for (long long(i) = 0; i < (N); ++(i)) d[i] = INF;
  d[u] = 0;
  while (true) {
    bool update = false;
    for (long long i = 0; i < 2 * N - 2; i++) {
      edge e = es[i];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if (!update) break;
  }
  vector<long long> tak(d);
  for (long long(i) = 0; i < (N); ++(i)) d[i] = INF;
  d[v] = 0;
  while (true) {
    bool update = false;
    for (long long i = 0; i < 2 * N - 2; i++) {
      edge e = es[i];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if (!update) break;
  }
  long long pos = 0;
  for (long long(i) = 0; i < (N); ++(i))
    if (tak[i] * d[i] > 0 && d[i] - tak[i] > 0 && d[pos] < d[i]) pos = i;
  cout << (tak[pos]) << endl;
  return 0;
}
