#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
using VVI = vector<VI>;
const int inf = 1e9;
void show(const VI &v) {
  for (int i = 0; i < v.size(); i++) {
    printf("%d: %d\n", i + 1, v[i]);
  }
}
VI make_dist(int st, const VVI &connect) {
  int n = connect.size();
  VI dist(n, inf);
  queue<int> que;
  que.push(st);
  dist[st] = 0;
  while (!que.empty()) {
    auto x = que.front();
    que.pop();
    for (auto y : connect[x]) {
      if (dist[y] == inf) {
        dist[y] = dist[x] + 1;
        que.push(y);
      }
    }
  }
  return dist;
}
int main() {
  int n, u, v, a, b;
  cin >> n >> u >> v;
  u--;
  v--;
  VVI connect(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    connect[a].push_back(b);
    connect[b].push_back(a);
  }
  int pos_t = u;
  int pos_a = v;
  auto dist_t = make_dist(pos_t, connect);
  auto dist_a = make_dist(pos_a, connect);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (dist_t[i] < dist_a[i]) {
      ans = max(ans, dist_t[i]);
    }
  }
  cout << ans << endl;
  return 0;
}
