#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void chmax(T& a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
void chmin(T& a, U b) {
  if (b < a) a = b;
}
vector<int> es[100100];
int dista[100100], distt[100100];
int rec(int u, int d) {
  if (dista[u] >= 0) return dista[u];
  dista[u] = d;
  for (auto v : es[u]) {
    rec(v, d + 1);
  }
  return dista[u];
}
int rec2(int u, int d) {
  if (distt[u] >= 0) return distt[u];
  distt[u] = d;
  for (auto v : es[u]) {
    rec(v, d + 1);
  }
  return distt[u];
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    es[a].push_back(b);
    es[b].push_back(a);
  }
  for (int i = 0; i < n; i++) dista[i] = distt[i] = -1;
  rec(v, 0);
  rec2(u, 0);
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    long long int tmp = dista[i] - 1;
    chmax(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
