#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 100000;
constexpr int INF = 1<<30;

vector<int> graph[N_MAX];

class LowestCommonAncestor {
    public:
    int root, n, LOG_V_MAX = 30;
    vector<int> depth;
    vector<vector<int>> parent;

    LowestCommonAncestor(int root=0, int n=N_MAX): root(root), n(n) {
        depth.assign(n, -1);
        parent.assign(n, vector<int>(LOG_V_MAX, -1));
        dfs(root, -1, 0);
        for(int j=1;j<LOG_V_MAX;++j) {
            for(int i=0;i<n;++i) {
                if(parent[i][j-1] == -1) continue;
                parent[i][j] = parent[parent[i][j-1]][j-1];
            }
        }
    }

    void dfs(int node, int par, int d) {
        depth[node] = d;
        parent[node][0] = par;
        for(int child: graph[node]) {
            int c = child;
            if(c == par) continue;
            dfs(c, node, d+1);
        }
    }

    int get_lca(int u, int v) {
        if(depth[u] > depth[v]) swap(u, v);
        int depth_diff = depth[v] - depth[u];
        for(int j=0;j<LOG_V_MAX;++j) {
            if(depth_diff & (1 << j)) {
                v = parent[v][j];
            }
        }
        if(u == v) return u;
        for(int j=LOG_V_MAX-1;j>=0;--j) {
            if(parent[u][j] != parent[v][j]) {
                u = parent[u][j];
                v = parent[v][j];
            }
        }
        return parent[u][0];
    }
    
    int get_dist(int u, int v) {
        return depth[u] + depth[v] - 2*depth[get_lca(u, v)];
    }
};

LowestCommonAncestor lca;

void move(int &player, int &dest) {
    for(int child: graph[player]) {
        if(lca.get_dist(player, dest) > lca.get_dist(child, dest)) {
            player = child;
            return;
        }
    }
    player = graph[player][0];
    return;
}

vector<int> depth_from_takahashi(N_MAX, INF);
 
void dfs(int node, int par, int d) {
    depth_from_takahashi[node] = d;
    for(int child: graph[node]) {
        if(child == par) continue;
        dfs(child, node, d+1);
    }
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, takahashi, aoki, a, b;
    cin >> n >> takahashi >> aoki;
    --takahashi; --aoki;
    for(int i=0;i<n-1;++i) {
        cin >> a >> b;
        --a; --b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    lca = LowestCommonAncestor(aoki, n);

    dfs(takahashi, -1, 0);

    int dest = takahashi;  // (高橋くんからの距離) < (青木くんからの距離) で青木くんからもっとも遠いノード
    int dest_dist = lca.depth[takahashi];
    for(int i=0;i<n;++i) {
        if(depth_from_takahashi[i] < lca.depth[i] &&  dest_dist < lca.depth[i]) {
            dest = i;
            dest_dist = lca.depth[i];
        }
    }
    int dest_lca = lca.get_lca(dest, takahashi);

    bool is_takahashi_turn = true;
    bool used_dest_lca = false;
    int ans = 0;
    while(takahashi != aoki) {
        if(is_takahashi_turn) {
            move(takahashi, (used_dest_lca?dest:dest_lca));
            if(takahashi == dest_lca) used_dest_lca = true;
        } else {
            move(aoki, takahashi);
            ++ans;
        }
        is_takahashi_turn ^= true;
    }

    cout << ans << endl;
}


Measured memory_bytes: 39040