#include <bits/stdc++.h>

using namespace std;

int n, u, v;

int dist[2][100002];
vector<int>G[100002];

void dfs (int nod, int p, int f) {
  for (auto it : G[nod])
    if (it != p) {
      dist[f][it] = dist[f][nod] + 1;
      dfs(it, nod, f);
    }
}

int main()
{
  cin >> n >> u >> v;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(u, -1, 0);
  dfs(v, -1, 1);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (dist[0][i] < dist[1][i])
      ans = max(ans, dist[1][i] - 1);
  cout << ans;
  return 0;
}
