#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;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) {
  return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) {
  return make_pair(l.first - r.first, l.second - r.second);
}
const long long int MOD = 1e9 + 7, INF = 1e18;
long long int dpT[100000], dpA[100000], N, u, v, a, b;
vector<long long int> to[100000];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> N >> u >> v;
  u--;
  v--;
  for (long long int i = (0), i_end_ = (N - 1); i < i_end_; i++) {
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    dpT[i] = INF;
    dpA[i] = INF;
  }
  queue<long long int> que;
  que.push(u);
  dpT[u] = 0;
  while (!que.empty()) {
    long long int curr = que.front();
    que.pop();
    for (long long int i = (0), i_end_ = (((long long int)(to[curr]).size()));
         i < i_end_; i++) {
      long long int next = to[curr][i];
      if (dpT[curr] + 1 < dpT[next]) {
        dpT[next] = dpT[curr] + 1;
        que.push(next);
      }
    }
  }
  que.push(v);
  dpA[v] = 0;
  while (!que.empty()) {
    long long int curr = que.front();
    que.pop();
    for (long long int i = (0), i_end_ = (((long long int)(to[curr]).size()));
         i < i_end_; i++) {
      long long int next = to[curr][i];
      if (dpA[curr] + 1 < dpA[next]) {
        dpA[next] = dpA[curr] + 1;
        que.push(next);
      }
    }
  }
  bool flag = (dpA[u] % 2 == 0);
  long long int maxv = 0;
  for (long long int i = (0), i_end_ = (N); i < i_end_; i++) {
    if (dpT[i] < dpA[i]) {
      chmax(maxv, dpT[i]);
    }
  }
  if (flag) maxv++;
  cout << maxv << endl;
}
