#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector<vector<int>> graph(n);
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  set<int> ts;
  set<int> as;
  ts.insert(u);
  as.insert(v);
  int cnt = 0;
  while (!ts.empty()) {
    set<int> tn;
    set<int> an;
    for (auto s : ts)
      for (auto node : graph[s])
        if (as.find(node) == as.end()) tn.insert(node);
    if (tn.empty()) break;
    cnt++;
    for (auto s : as)
      for (auto node : graph[s]) an.insert(node);
    as = an;
    ts.clear();
    for (auto s : tn)
      for (auto node : graph[s])
        if (as.find(node) == as.end()) ts.insert(node);
  }
  cout << cnt << endl;
  return 0;
}
