#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
signed main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector<int>* edge = new vector<int>[n];
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  vector<P>* ok = new vector<P>[n * 2 + 1];
  ok[0].push_back(P(u, v));
  for (int i = 0; i < (int)(n - 1); i++) {
    if (ok[i * 2].size() == 0) {
      cout << (i) << endl;
      return 0;
    }
    bool* b0 = new bool[n];
    fill(b0, b0 + n, true);
    vector<P> nv0;
    int sz0 = ok[i * 2].size();
    for (int j = 0; j < (int)(sz0); j++) {
      P p = ok[i * 2][j];
      int tmp = edge[p.first].size();
      for (int k = 0; k < (int)(tmp); k++) {
        if (p.second != edge[p.first][k])
          nv0.push_back(P(edge[p.first][k], p.second));
        else
          b0[p.second] = false;
      }
    }
    int szn0 = nv0.size();
    for (int j = 0; j < (int)(szn0); j++) {
      if (b0[nv0[j].first]) ok[i * 2 + 1].push_back(nv0[j]);
    }
    if (ok[i * 2 + 1].size() == 0) {
      cout << (i) << endl;
      return 0;
    }
    bool* b = new bool[n];
    fill(b, b + n, true);
    vector<P> nv;
    int sz = ok[i * 2 + 1].size();
    for (int j = 0; j < (int)(sz); j++) {
      P p = ok[i * 2 + 1][j];
      int tmp = edge[p.second].size();
      for (int k = 0; k < (int)(tmp); k++) {
        if (p.first != edge[p.second][k])
          nv.push_back(P(p.first, edge[p.second][k]));
        else
          b[p.first] = false;
      }
    }
    int szn = nv.size();
    for (int j = 0; j < (int)(szn); j++) {
      if (b[nv[j].first]) ok[i * 2 + 2].push_back(nv[j]);
    }
  }
}
