#include <bits/stdc++.h>
using namespace std;
int d[100010], c[100010];
vector<int> g[100010];
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  --v, --u;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    g[--a].emplace_back(--b);
    g[b].emplace_back(a);
  }
  queue<int> q;
  q.push(v);
  d[v] = 1;
  while (!q.empty()) {
    v = q.front();
    q.pop();
    for (int w : g[v])
      if (!d[w]) {
        q.push(w);
        d[w] = d[v] + 1;
      }
  }
  q.push(u);
  c[u] = 1;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int w : g[u])
      if (c[u] < d[w]) {
        c[w] = c[u] + 1;
        q.push(w);
      }
    if (q.empty()) {
      int res = 0;
      for (int w : g[u]) res = max(res, d[w]);
      cout << res - 1 << endl;
      return 0;
    }
  }
}
