#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const int bound = 100010;
const int tkhs = 0;
const int aok = 1;
vector<int> graph[bound];
bool bscht[bound][2];
int dist[bound][2];

void dfs( char mode, int now, int d = 0 ){
	bscht[now][mode] = true;
	dist[now][mode] = d;
	for( auto next : graph[now] ){
		if( bscht[next][mode] ) continue;
		dfs( mode, next, d+1 );
	}
}
int main(){
	int n, u, v; cin >> n >> u >> v; 
	--u; --v;
	for( int i = 0; i < n-1; ++i ){
		int a, b; cin >> a >> b;
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	dfs(tkhs, u);
	dfs(aok, v);
	int ans = 0;
	for( int i = 0; i < n; ++i){
		if( dist[i][tkhs] < dist[i][aok] ){
			ans = max(ans, dist[i][aok]-1);
		}
	}
	cout << ans << endl;
}