#include <bits/stdc++.h>
using namespace std;
 
const int N = 2e5 + 10;
 
vector<int> G[N];
vector<int> depth, p;
int dep, x;
 
void dfs(int v, int pai, int d) {
 
    depth[v] = d;
    if(v == x) dep = d;
    for(int u : G[v]) if(u != pai) {
        dfs(u, v, d + 1);
        depth[v] = max(depth[v], depth[u]); 
        p[u] = v;
    }
 
}
 
int main() {
    ios::sync_with_stdio(false);
 
    int n, y; cin >> n >> x >> y; y--; x--;
    depth.resize(n);
    p.resize(n);
    for(int i = 0; i < n - 1; i++) {
        int u, v; cin >> u >> v; --u; --v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
 
    dfs(y, -1, 0);
    int turns = (dep - 1) / 2;
    p[0] = 0;
    while(turns) {
        x = p[x];
        turns--;
    }
 
    cout << depth[x] - 1 << '\n';
 
 
    return 0;
}