#include <bits/stdc++.h>
using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  Graph G(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    G.at(a - 1).push_back(b - 1);
    G.at(b - 1).push_back(a - 1);
  }
  vector<pair<int, int>> dis(n, make_pair(-1, -1));
  queue<int> que;
  que.push(u);
  dis.at(u).first = 0;
  while (!que.empty()) {
    int cur = que.back();
    que.pop();
    for (int x : G.at(cur)) {
      if (dis.at(x).first != -1) {
        continue;
      }
      dis.at(x).first = dis.at(cur).first + 1;
      que.push(x);
    }
  }
  que.push(v);
  dis.at(v).second = 0;
  while (!que.empty()) {
    int cur = que.back();
    que.pop();
    for (int x : G.at(cur)) {
      if (dis.at(x).second != -1) {
        continue;
      }
      dis.at(x).second = dis.at(cur).second + 1;
      que.push(x);
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (dis.at(i).first < dis.at(i).second) {
      if ((dis.at(i).second - dis.at(i).first) % 2 == 0) {
        ans = max(ans, dis.at(i).second);
      } else {
        ans = max(ans, dis.at(i).second - 1);
      }
    }
  }
  int tmp = -1;
  bool onlyone = true;
  for (int i = 0; i < n; i++) {
    if (dis.at(i).first == 1) {
      if (tmp != -1) {
        onlyone = false;
        break;
      } else {
        tmp = i;
      }
    }
  }
  if (onlyone && dis.at(tmp).second == 1) {
    ans = 1;
  }
  cout << ans << endl;
  return 0;
}
