#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000;
long long int mod = 1e9 + 7;
vector<vector<int>> vv(maxn);
int n, u, v;
int disu[maxn], disv[maxn];
int main() {
  cin >> n >> u >> v;
  u--;
  v--;
  for (long long int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    vv[a].push_back(b);
    vv[b].push_back(a);
  }
  fill(disu, disu + n, 1e9 + 7);
  fill(disv, disv + n, 1e9 + 7);
  disu[u] = 0, disv[v] = 0;
  queue<int> que;
  que.push(u);
  while (!que.empty()) {
    int arg = que.front();
    que.pop();
    for (int i = 0; i < vv[arg].size(); i++) {
      int to = vv[arg][i];
      if (disu[to] == 1e9 + 7) {
        disu[to] = disu[arg] + 1;
        que.push(to);
      }
    }
  }
  que.push(v);
  while (!que.empty()) {
    int arg = que.front();
    que.pop();
    for (int i = 0; i < vv[arg].size(); i++) {
      int to = vv[arg][i];
      if (disv[to] == 1e9 + 7) {
        disv[to] = disv[arg] + 1;
        que.push(to);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i != u && i != v) {
      if (disv[i] - disv[u] == disu[i]) {
        ans = max(ans, disu[i]);
      } else {
        ans = max(ans, disv[i] - disu[i]);
      }
    }
  }
  ans += disu[v] / 2;
  cout << ans << endl;
  return 0;
}
