#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e16;
const long long MOD = 1e9 + 7;
const long long MB = 20;
vector<vector<long long>> g;
void dfs(long long v, vector<long long>& h, long long pr = -1) {
  for (long long u : g[v]) {
    if (u != pr) {
      h[u] = h[v] + 1;
      dfs(u, h, v);
    }
  }
}
void solve() {
  long long n, v, u;
  cin >> n >> v >> u;
  v--;
  u--;
  g.resize(n);
  for (long long i = 0; i < n - 1; i++) {
    long long from, to;
    cin >> from >> to;
    from--;
    to--;
    g[from].push_back(to);
    g[to].push_back(from);
  }
  vector<long long> h1(n), h2(n);
  dfs(v, h1);
  dfs(u, h2);
  long long ans = 0;
  bool good = false;
  for (long long i : g[v]) {
    if (i != u) good = true;
  }
  if (good) ans = 1;
  for (long long i = 0; i < n; i++) {
    if (h1[i] < h2[i]) {
      ans = max(ans, h1[i]);
    }
  }
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed;
  cout.precision(12);
  solve();
}
