#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 (auto e: G[v]){
            if (d[e.to] > d[v] + e.cost){
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
    return;
}

int dfs(int v, int dist) {
    // �s�����������C���N�������g���Ȃ��烁��
    int res = 0; // �c��[����������
    d[v] = dist;   // �[����o�^
    seen[v] = true; // v ��K��ςɂ���
    for (auto e: G[v]){
        if (seen[e.to]) continue; 
        res = max(dfs(e.to, dist + 1), res);
    }

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

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

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�ɏ�����
    dfs(S, 0);
    
    nnext.assign(V, -1); // �S���_�����K���
    int c = T;
    while(1){
        int next;
        for (auto &e: G[c]){
           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 (auto &e: G[a]){
                if (d[e.to] < d[a]){
                    next = e.to;
                    break;
                }
            }
        } else {
            int cost = -1;
            for (auto &e: G[a]){
                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