#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
int n, u, v, a, b;
vector<int> tree[100010];
int flag1[100010];
int flag2[100010];
void dfs(int ud, int m, int flag[]) {
  for (auto vd : tree[ud]) {
    if (vd != m) {
      flag[vd] = flag[ud] + 1;
      dfs(vd, ud, flag);
    }
  }
}
void solve() {
  cin >> n >> u >> v;
  u--;
  v--;
  for (int64_t i = (0); i < (n - 1); i++) {
    cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  dfs(u, -1, flag1);
  dfs(v, -1, flag2);
  int ans = 0;
  for (int64_t i = (0); i < (n); i++) {
    if (flag1[i] > flag2[i]) ans = max(ans, flag1[i]);
  }
  cout << ans - 1 << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
