#include <bits/stdc++.h>
using namespace std;
const long long linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;
vector<int> g[100005];
int n;
vector<int> res;
void dfs(int v, int p = -1, int cnt = 0) {
  res[v] = cnt;
  for (int c : g[v]) {
    if (c == p) continue;
    dfs(c, v, cnt + 1);
  }
}
vector<int> distcalc(int a) {
  res = vector<int>(n);
  dfs(a);
  return res;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  auto distA = distcalc(u);
  auto distT = distcalc(v);
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    if (distA[i] < distT[i]) ans = max(ans, distT[i]);
  }
  cout << ans << endl;
  return 0;
}
