//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1 << 17;

struct node {
	vector<int> N;
	int dlt = 0, dsn = 0;
} G[maxN];

void DFS_lt(int v, int u, int d) {
	G[v].dlt = d;
	for(int w : G[v].N) 
		if(w != u)
			DFS_lt(w, v, d + 1);
}

void DFS_sn(int v, int u, int d) {
	G[v].dsn = d;
	for(int w : G[v].N) 
		if(w != u)
			DFS_sn(w, v, d + 1);
}

int main() {
	int n, lt, sn; cin >> n >> lt >> sn;
	for(int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		G[v].N.push_back(u);
		G[u].N.push_back(v);
	}
	DFS_lt(lt, -1, 0);
	DFS_sn(sn, -1, 0);
	int r = 0;
	for(int i = 1; i <= n; i++)
		if(G[i].N.size() == 1 && G[i].dlt < G[i].dsn)
			r = max(r, G[G[i].N[0]].dsn);
	cout << r;
}
