#include <bits/stdc++.h>
using namespace std;
vector<long long int> adj[100009];
long long int d[100009][2];
void fun(long long int x, bool f) {
  for (long long int y : adj[x])
    if (d[y][f] == -1) {
      d[y][f] = d[x][f] + 1;
      fun(y, f);
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  long long int x, y;
  for (long long int i = 0; i < n - 1; i++) {
    long long int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  memset(d, -1, sizeof(d));
  d[u][0] = d[v][1] = 0;
  fun(u, 0);
  fun(v, 1);
  long long int ans = 0;
  for (long long int i = 0; i < n; i++)
    if (d[i][0] < d[i][1]) ans = max(ans, d[i][1]);
  cout << ans - 1 << endl;
}
