#include<bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;

int n;
int a, t;
vector<int> vec[100003];

int jar[100003][2];
void dfs(int u, int par, int x)
{
	for(int v : vec[u])
	{
		if(v == par) continue;
		jar[v][x] = jar[u][x]+1;
		dfs(v, u, x);
	}
}

int main()
{
	// freopen("input.in", "r", stdin);

	scanf("%d %d %d", &n, &t, &a);
	for(int i = 1; i < n; i++)
	{
		int u, v; scanf("%d %d", &u, &v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	dfs(a, -1, 0);
	dfs(t, -1, 1);
	int mx = 0;
	for(int i = 1; i <= n; i++)
	{
		if(jar[i][0] > jar[i][1]) 
			mx = max(mx, jar[i][0]);
	}
	printf("%d\n", max(mx-1, 0));
}