#include <bits/stdc++.h>
using namespace std;
int n, u, v;
vector<int> adj[100100];
int deg[100100];
int ans = 0, mxd;
void dfs(int cur, int prev, int dep) {
  deg[cur] = dep;
  for (int v : adj[cur]) {
    if (v != prev) dfs(v, cur, dep + 1);
  }
}
void dfss(int cur, int prev) {
  ans = max(ans, deg[cur]);
  for (int v : adj[cur]) {
    if (cur != prev && deg[v] > mxd) dfss(v, cur);
  }
}
int main() {
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(u, -1, 0);
  mxd = deg[v];
  dfss(v, -1);
  cout << ans << '\n';
}
