#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long

vector<int>g[100000];
int n, u, v, a, b, ans;
int du[100000], dv[100000];

//Graph ⇒ std::vector<int> v[100]; 100 verices
void dfs(int x, int y, int z) {
	dv[x] = z;
	for (int i = 0; i < g[x].size(); i++) {
		if (g[x][i] != y)dfs(g[x][i], x, z + 1);
	}
}

int main() {
  scanf("%d%d%d", &n, &u, &v);
	u--; v--;
	for (int i = 0; i < n - 1; i++) {
		scanf("%d%d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

  dfs(u, -1, 0);
for (int i = 0; i < n; i++)du[i] = dv[i];
dfs(v, -1, 0);
for (int i = 0; i < n; i++) {
  if (dv[i] > du[i]) {
    if (dv[i] > ans)ans = dv[i];
  }
}
printf("%d\n", ans - 1);

  return 0;
}

