#include <bits/stdc++.h>
long long INF = (1ll << 61);
using namespace std;
long long u, v, t;
vector<long long>* g;
long long dep[100005];
long long dfs(int V, int pV, int h) {
  dep[V] = h;
  bool b = (V == u);
  for (auto k : g[V]) {
    if (k == pV) continue;
    if (dfs(k, V, h + 1)) {
      if (h == (dep[u] + 1) / 2) {
        t = k;
      }
      b = 1;
    }
  }
  return b;
}
long long dfs2(int V, int pV) {
  long long ans = dep[V];
  for (auto k : g[V]) {
    if (k == pV) continue;
    ans = max(ans, dfs2(k, V));
  }
  return ans;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n >> u >> v;
  g = new vector<long long>[n + 1];
  for (int i = 0; i < n - 1; i++) {
    long long a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(v, -1, 0);
  long long k = dfs2(t, -1);
  cout << k - 1 << endl;
  return 0;
}
