#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353

vector<vector<ll>> connec(110000);
vector<ll> l1(110000,0);
vector<ll> reached1(110000, false);
vector<ll> l2(110000,0);

void dfs1(ll x){
	cout << "dfs1" << x << endl;
	reached1[x] = true;
	if (connec[x].size()!=0){
		REP(i,connec[x].size()){
			if (reached1.at(connec[x][i])==false){
				cout << "つながり" << connec[x][i] << endl;
				l1.at(connec[x][i]) = l1.at(x)+1;
				dfs1(connec[x][i]);
			}
		}
	}
	return;
}

void dfs2(ll x){
	cout << "dfs2" << x << endl;
	if (l2.at(x)!=-1){
		ll cnter = l2.at(x)+1;
		REP(i,connec[x].size()){
			if (l2.at(connec[x][i])==-1){
				continue;
			}
			else if (l1.at(connec[x][i]) <= cnter){
				continue;
			}
			else{
				cout << "つながり" << connec[x][i] << endl;
				l2.at(connec[x][i]) = cnter;
				dfs2(connec[x][i]);
			}
		}
	}
	return;
}


int main(){
	ll n, u, v; cin >> n >> u >> v;
	REP(i,n){
		ll a, b; cin >> a >> b;
		connec[a-1].pb(b-1);
		connec[b-1].pb(a-1);
	}
	dfs1(v-1);
	dfs2(u-1);
	ll ans = 0;
	REP(i,n) {
		ans = max(ans,l2.at(i));

	}
	if (l2.at(i) == l1.at(i)){
		ans += 1
	}
	cout << ans << endl;
}