#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
const int MOD = 1000000007;
vector<int> to[100000];
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i = 0; i < (n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> m(n - 1, -1);
  vector<int> c(n - 1, -1);
  m[u] = 0;
  c[v] = 0;
  queue<int> q;
  q.push(u);
  while (int(q.size())) {
    int a = q.front();
    q.pop();
    for (auto s : to[a]) {
      if (m[s] == -1) {
        q.push(s);
        m[s] = m[a] + 1;
      }
    }
  }
  q.push(v);
  while (int(q.size())) {
    int a = q.front();
    q.pop();
    for (auto s : to[a]) {
      if (c[s] == -1) {
        q.push(s);
        c[s] = c[a] + 1;
      }
    }
  }
  int ans = 0;
  if (n != 2) {
    for (int i = 0; i < (n - 1); i++) {
      if (m[i] <= c[i]) {
        int tmp = c[i] - abs(c[i] - m[i] - 1) % 2;
        ans = max(ans, tmp);
      }
    }
  }
  cout << (ans) << endl;
  return 0;
}
