#include <bits/stdc++.h>
using namespace std;
int n, s, t, a[101010], b[101010], ky[101010];
vector<int> v[101010];
int main() {
  cin >> n >> s >> t;
  s--;
  t--;
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    v[a[i]].push_back(b[i]);
    v[b[i]].push_back(a[i]);
  }
  int ans = 0;
  bool used[101010] = {0};
  queue<pair<long long, long long> > q;
  q.push(pair<long long, long long>(t, 0));
  used[t] = 1;
  while (!q.empty()) {
    pair<long long, long long> p = q.front();
    q.pop();
    int pos = p.first, now = p.second;
    ky[pos] = now;
    for (int i = 0; i < v[pos].size(); i++) {
      if (used[v[pos][i]]) continue;
      used[v[pos][i]] = 1;
      q.push(pair<long long, long long>(v[pos][i], now + 1));
    }
  }
  int must = ky[t] / 2 - !(ky[t] % 2);
  int ma = 0;
  bool used2[101010] = {0};
  queue<int> qq;
  qq.push(s);
  used2[s] = 1;
  while (!qq.empty()) {
    int p = qq.front();
    qq.pop();
    ma = max(ma, ky[p]);
    for (int j = 0; j < v[p].size(); j++) {
      if (used2[v[p][j]]) continue;
      if (ky[v[p][j]] <= must) continue;
      used2[v[p][j]] = 1;
      qq.push(v[p][j]);
    }
  }
  cout << ma - 1 << endl;
  return 0;
}
