//In the name of God
//SMani24
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 100;

int n, a[N], r0, r1;
int h[2][N], ans;
vector<int> adj[N];

void dfs(int v = 0, int par = -1, int f = 0) {
	for (int u : adj[v]) 
		if (u != par) {
			h[f][u] = h[f][v] + 1;
			dfs(u, v, f);
		}
}

int main() {
	cin >> n >> r0 >> r1;
	r0--, r1--;
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	dfs(r0, -1, 0);
	dfs(r1, -1, 1);
	for (int i = 0; i < n; i++)
		if (h[1][i] < h[0][i])
			continue;
		else {
			int t = h[1][i] - h[0][i];
			ans = max(ans, h[1][i] - 1);
		}
	cout << ans << endl;
	return 0;
}
