#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar) {
  for (int i = 0; i < (ar.size() - 1); ++i) cout << ar[i] << " ";
  cout << ar[ar.size() - 1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar) {
  for (int i = 0; i < (ar.size()); ++i) {
    for (int j = 0; j < (ar[0].size() - 1); ++j) cout << ar[i][j] << " ";
    cout << ar[i][ar[0].size() - 1] << endl;
  }
}
template <typename S>
bool range(S a, S b, S x) {
  return (a <= x && x < b);
}
struct edge {
  vector<int> to;
  int ko;
  int oya;
  int dist;
};
int main() {
  int n;
  cin >> n;
  int u, v;
  cin >> u >> v;
  u--;
  v--;
  vector<edge> ar(n);
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    ar[a - 1].to.emplace_back(b - 1);
    ar[b - 1].to.emplace_back(a - 1);
  }
  int ans = 0;
  for (int i = 0; i < (n); ++i) ar[i].ko = -1;
  stack<int> st;
  st.push(v);
  ar[v].oya = -1;
  ar[v].dist = 0;
  while (!st.empty()) {
    int g = st.top();
    st.pop();
    if (g == -1) break;
    ar[g].ko = -2;
    bool t = true;
    int mi = 0;
    for (int i = 0; i < (ar[g].to.size()); ++i) {
      int c = ar[ar[g].to[i]].ko;
      if (c == -1) {
        st.push(ar[g].to[i]);
        ar[ar[g].to[i]].oya = g;
        ar[ar[g].to[i]].dist = ar[g].dist + 1;
        t = false;
        break;
      } else if (c != -2) {
        mi = max(mi, c + 1);
      }
    }
    if (t) {
      ar[g].ko = mi;
      st.push(ar[g].oya);
    }
  }
  int nu = u;
  for (int i = 0; i < ((ar[u].dist - 1) / 2); ++i) {
    nu = ar[nu].oya;
    ans++;
  }
  if ((ar[u].dist - 1) % 2 == 0) {
    ans += ar[nu].ko;
  } else {
    ans += ar[nu].ko + 1;
  }
  cout << ans << endl;
}
