#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
vvi Graph(100100);
vi dist(100100);
int T;
void dfs(int v, int pv, int depth = 0) {
  dist.at(v) = depth;
  for (int nv : Graph.at(v)) {
    if (nv == pv) continue;
    dfs(nv, v, depth + 1);
  }
}
void dfs1(int v, int &d) {
  d = max(d, dist.at(v));
  for (int nv : Graph.at(v)) {
    if (dist.at(nv) < dist.at(v)) continue;
    dfs1(nv, d);
  }
}
int main() {
  int n, A;
  cin >> n >> T >> A;
  T--;
  A--;
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    Graph.at(a).push_back(b);
    Graph.at(b).push_back(a);
  }
  dist.at(0) = 0;
  dfs(0, -1);
  int diff = dist.at(T);
  int step = (diff - 1) / 2;
  int pos = T;
  for (int i = 0; i < (int)(step); i++) {
    for (int nv : Graph.at(pos)) {
      if (dist.at(nv) < dist.at(pos)) {
        pos = nv;
        break;
      }
    }
  }
  int maxd = dist.at(pos);
  dfs1(pos, maxd);
  int ans = step + maxd - dist.at(pos) + !(diff % 2);
  cout << ans << endl;
}
