#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
void bfs(vector<vector<ll>>& edges, vector<ll>& dist, ll place, ll d) {
  dist[place] = d;
  for (ll nx : edges[place]) {
    if (dist[nx] != 10000000000000000ll) continue;
    bfs(edges, dist, nx, d + 1);
  }
  return;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  vector<vector<ll>> edges(n);
  for (int i = 0; i < n - 1; i++) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edges[a].emplace_back(b);
    edges[b].emplace_back(a);
  }
  vector<ll> dist_aoki(n, 10000000000000000ll);
  bfs(edges, dist_aoki, v, 0);
  ll ans = -1;
  for (int i = 0; i < n; i++) ans = max(ans, dist_aoki[i]);
  cout << ans - 1 << endl;
}
