#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
typedef pair<int, int> i_i;
ll INF = 1e12+10;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
vector<pair<ll, ll> > pairs;
#define print1(x) cerr << "x = " << x << endl;
#define print2(x, y) cerr<< "x,y = "  << x << "," << y << endl;
#define print3(x, y, z) cerr << "x,y,z = " << x << "," << y << "," << z << endl;
#define print4(x, y, z, w) cerr << "x,y,z,w = " << x << "," << y << "," << z << "," << w << endl;
const ll MAX = ll(1e10) * 300 + 10;
#define MAX_V int(2e5 + 1)
#define INF (1000000000LL) // * 100000000LL)

struct edge{int to, cost;};
typedef pair<int, int> P;

vector<edge> G[MAX_V];
int d[MAX_V], depth[MAX_V];
vector<bool> seen;
vector<int> nnext;
int S, T, V;

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));
    
    while (!que.empty()){
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        for (int i = 0; i < G[v].size(); i++){
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    //fprintf(stderr, "%d, %d, %d\n", V, T, S);
    //for (int i = 0; i < V; i++){
    //    fprintf(stderr, "%d, %d: %d\n", s, i, d[i]);
    //}
    //exit(1);
    return;
}

int dfs(int v) {
    // �s�����������C���N�������g���Ȃ��烁��
    int dep = 0;
    seen[v] = true; // v ��K��ςɂ���
    for (int i = 0; i < G[v].size(); i++){
        edge e = G[v][i];
        if (seen[e.to]) continue; 
        int tmp = dfs(e.to);
        dep = max(tmp, dep);
    }

    // �A�肪�������C���N�������g���Ȃ��烁��
    depth[v] = dep + 1;
    return depth[v];
}

////////////////////////////////////////

int main() {
    int ans = 0;
    cin >> V >> T >> S;
    S--;
    T--;
    vector<int> A(V), B(V), C(V);
    for (int i = 0; i < V - 1; i++){
        cin >> A[i] >> B[i];
        C[i] = 1;
        G[A[i] - 1].push_back((edge){B[i] - 1, C[i]});
        G[B[i] - 1].push_back((edge){A[i] - 1, C[i]});
    }
    
    
    
    dijkstra(S);
    seen.assign(V, false); // �S���_���u���K��v�ɏ�����
    nnext.assign(V, -1); // �S���_���u���K��v�ɏ�����
    dfs(S);
    
    int c = T;
    while(1){
        int next;
        
        for (int i = 0; i < G[c].size(); i++){
           edge e = G[c][i];
           if (d[e.to] < d[c]){
                next = e.to;
                break;
           }
        }
        
        nnext[next] = c;
        if (next == S){
            break;
        }
        c = next;
    }
    
    int a = T, b = S;
    while (1){
        if (a == b){
            break;
        }
        int next = -1;
        
        //fprintf(stderr, "aaa a, b = (%d, %d), %d, %d \n", a + 1, b + 1, d[a], d[b]);
        
        if (G[a].size() == 1){
            next = G[a][0].to;
        } else if (d[a] > d[b] + 2){
            for (int i = 0; i < G[a].size(); i++){
                edge e = G[a][i];
                if (d[e.to] < d[a]){
                    next = e.to;
                    break;
                }
            }
        } else {
            int cost = -1;
            for (int i = 0; i < G[a].size(); i++){
                edge e = G[a][i];
                if (d[e.to] > d[a] && depth[e.to] > cost){
                    cost = depth[e.to];
                    next = e.to;
                    //fprintf(stderr, "###  %d -> %d\n", a + 1, e.to + 1);
                }
            }
        }
        nnext[a] = next;
        a = next;
        
        //fprintf(stderr, "a = %d\n", a + 1);
        if (a == b){
            break;
        }
        b = nnext[b];
        ans++;

        //fprintf(stderr, "b = %d\n", b + 1);
        
    }
        
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14464