#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<long long> G[100010];
  for (long long i = 0; i < N - 1; i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if (G[u].size() == 1) {
    if (G[u][0] == v) {
      cout << 0 << endl;
      return 0;
    }
  }
  vector<long long> d(N);
  for (long long i = 0; i < N; i++) d[i] = 1000000000;
  queue<pair<long long, long long> > Q;
  Q.push(pair<long long, long long>(v, 0));
  while (!Q.empty()) {
    long long a = Q.front().first, cnt = Q.front().second;
    Q.pop();
    d[a] = cnt;
    for (long long i = 0; i < G[a].size(); i++) {
      if (d[G[a][i]] == 1000000000)
        Q.push(pair<long long, long long>(G[a][i], cnt + 1));
    }
  }
  long long ans = 0;
  for (long long i = 0; i < N; i++) {
    if (G[i].size() == 1) {
      chmax(ans, d[G[i][0]]);
    }
  }
  cout << ans << endl;
  return 0;
}
