#include <bits/stdc++.h>
using namespace std;

int p[111111], h[111111], d[111111];
vector<vector<int>> g;
int f(int w, int x, int k) {
    d[x] = k;
    int m = -1;
    for(int y : g[x]) {
        if(y == w)
            continue;
        p[y] = x;
        m = max(m, f(x, y, k + 1));
    }
    return h[x] = m + 1;
}
int main() {
    int n, u, v;
    cin >> n >> u >> v;
    g.resize(n + 1);
    for(int i = 1; i < n; i++) {
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    f(0, v, 0);
    int l = (d[u] - 1) / 2;
    while(l--)
        u = p[u];
    cout << h[u] + d[u] - 1 << endl;
    return 0;
}
