#include<iostream>
#include<vector>

using namespace std;

vector<int> to[100000], dist;

void dfs(int cur, int d, int p) {
    dist[cur] = d;
    for (auto v : to[cur]) {
        if (v == p) continue;
        dfs(v, d + 1, cur);
    }
}

int main(void) {
    int n, u, v; cin >> n >> u >> v;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        to[a - 1].push_back(b - 1);
        to[b - 1].push_back(a - 1);
    }
    dist = vector<int>(n);
    vector<int> dist_t, dist_a;
    dfs(u - 1, 0, u - 1);
    dist_t = dist;
    dfs(v - 1, 0, v - 1);
    dist_a = dist;
    int mx = 0;
    for (int i = 0; i < n; i++) {
        if (dist_t[i] < dist_a[i]) {
            mx = max(mx, dist_a[i]);
        }
    }
    cout << mx - 1 << endl;
}