#include <bits/stdc++.h>
using namespace std;
int n, ta, ao, a, b, vertex;
vector<int> v[100001];
vector<int> parent;
vector<int> res;
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;
    }
    if (distance[i] > ans && i != ta) {
      ans = distance[i];
      res.push_back(i);
    }
  }
}
void dfs(int x, int p) {
  parent[x] = p;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != p) {
      dfs(v[x][i], x);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> ta >> ao;
  ta--;
  ao--;
  if (n == 2) {
    cout << 0;
    return 0;
  }
  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);
  int f = 0;
  int t1 = ta, t2 = ao;
  for (int i = 0; i < res.size(); i++) {
    vertex = res[i];
    parent.resize(n);
    for (int i = 0; i < n; i++) {
      parent[i] = -1;
    }
    dfs(vertex, -1);
    int ans = 0, prev_ta = t1, prev_ao = t2;
    ta = t1;
    ao = t2;
    while (true) {
      if (ta == ao) {
        break;
      }
      if (ta == vertex) {
        ta = prev_ta;
      } else if (ta != vertex) {
        prev_ta = ta;
        ta = parent[ta];
      }
      if (ta == ao) {
        break;
      }
      if (ao == vertex) {
        ao = prev_ao;
        ans++;
      } else if (ao != vertex) {
        prev_ao = ao;
        ao = parent[ao];
        ans++;
      }
    }
    f = max(f, ans);
  }
  cout << f;
}
