#include <bits/stdc++.h>
using namespace std;
int n, ta, ao, a, b;
vector<int> v[100001];
void d(int x) {
  vector<int> distance(n, 1000000000);
  vector<bool> visited(n);
  priority_queue<pair<int, int> > q;
  q.push(make_pair(0, x));
  distance[x] = 0;
  while (!q.empty()) {
    a = q.top().second;
    q.pop();
    if (visited[a]) {
      continue;
    }
    visited[a] = 1;
    for (int i = 0; i < v[a].size(); i++) {
      b = v[a][i];
      if (distance[a] + 1 < distance[b]) {
        distance[b] = distance[a] + 1;
        q.push(make_pair(-distance[b], b));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (distance[i] == 1000000000) {
      continue;
    }
    ans = max(ans, distance[i]);
  }
  cout << ans - 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> ta >> ao;
  ta--;
  ao--;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  d(ao);
}
