#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int vis[2][N];
vector<int> G[N];
void dfs(int s, int p, int t, int dis = 0) {
  vis[t][s] = dis;
  for (auto it : G[s]) {
    if (it == p) continue;
    dfs(it, s, t, dis + 1);
  }
}
int main() {
  int n, a, b;
  cin >> n >> a >> b;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(a, -1, 0);
  dfs(b, -1, 1);
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans = max(ans, vis[0][i] - vis[1][i]);
  cout << ans << endl;
  return 0;
}
