#include <bits/stdc++.h>
using namespace std;
int t[100005], a[100005];
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector<int> g[100005];
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 0; i < (n); ++i) {
    t[i] = -1;
    a[i] = -1;
  }
  t[u] = 0;
  a[v] = 0;
  queue<int> q;
  q.push(v);
  while (q.size()) {
    int v1 = q.front();
    q.pop();
    for (int v2 : g[v1]) {
      if (a[v2] != -1) continue;
      a[v2] = a[v1] + 1;
      q.push(v2);
    }
  }
  q.push(u);
  int ma = 0, ma_v2 = v, ma_v1 = v;
  while (q.size()) {
    int v1 = q.front();
    q.pop();
    for (int v2 : g[v1]) {
      if (t[v2] != -1) continue;
      if (a[v2] <= t[v1] + 1) {
        if (ma < a[v2]) {
          ma = a[v2];
          ma_v1 = v1;
          ma_v2 = v2;
          t[v2] = t[v1] + 1;
        }
        continue;
      }
      t[v2] = t[v1] + 1;
      if (ma < a[v2]) {
        ma = a[v2];
        ma_v1 = v1;
        ma_v2 = v2;
      }
      q.push(v2);
    }
  }
  if (t[ma_v2] == a[ma_v2]) {
    cout << a[ma_v2] << endl;
  } else {
    cout << a[ma_v1] << endl;
  }
  return 0;
}
