#include <bits/stdc++.h>
int main() {
  int N, u, v;
  std::cin >> N >> u >> v;
  u--;
  v--;
  std::vector<std::vector<int>> edge(N);
  for (int i = 1; i < N; i++) {
    int a, b;
    std::cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  std::set<int> s, t;
  std::vector<int> flag(N, 0);
  flag[u] = 1;
  flag[v] = 2;
  t.insert(u);
  s.insert(v);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    std::vector<int> t_sub;
    for (auto it = t.begin(); it != t.end();) {
      for (auto e : edge[*it]) {
        if (flag[e] == 2) {
          continue;
        }
        t_sub.push_back(e);
        flag[e] = 1;
      }
      it = t.erase(it);
    }
    for (auto t_s : t_sub) {
      t.insert(t_s);
    }
    if (t.empty()) {
      std::cout << ans << std::endl;
      return 0;
    }
    ans++;
    std::vector<int> s_sub;
    for (auto it = s.begin(); it != s.end();) {
      for (auto e : edge[*it]) {
        if (flag[e] == 2) {
          continue;
        }
        if (flag[e] == 1 && t.size() <= 1u) {
          std::cout << ans << std::endl;
          return 0;
        }
        s_sub.push_back(e);
        flag[e] = 2;
        t.erase(e);
      }
      it = s.erase(it);
    }
    for (auto s_s : s_sub) {
      s.insert(s_s);
    }
  }
  std::cout << "nothing" << std::endl;
  return 0;
}
