#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int INF = 99999999999999999;
long long int n, v, u;
long long int useda[100003] = {}, usedt[100003] = {};
long long int a[100003], b[100003], aoki[100003] = {}, takahashi[100003] = {};
vector<long long int> ed[100004];
queue<long long int> taska, taskt;
int main() {
  cout << fixed << setprecision(18);
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i] >> b[i];
    ed[a[i]].push_back(b[i]);
    ed[b[i]].push_back(a[i]);
  }
  taska.push(v);
  useda[v] = 1;
  while (!taska.empty()) {
    for (int i = 0; i < ed[taska.front()].size(); i++) {
      if (useda[ed[taska.front()][i]] == 0) {
        useda[ed[taska.front()][i]] = 1;
        aoki[ed[taska.front()][i]] = aoki[taska.front()] + 1;
        taska.push(ed[taska.front()][i]);
      }
    }
    taska.pop();
  }
  taskt.push(u);
  usedt[u] = 1;
  while (!taskt.empty()) {
    for (int i = 0; i < ed[taskt.front()].size(); i++) {
      if (usedt[ed[taskt.front()][i]] == 0) {
        usedt[ed[taskt.front()][i]] = 1;
        takahashi[ed[taskt.front()][i]] = takahashi[taskt.front()] + 1;
        taskt.push(ed[taskt.front()][i]);
      }
    }
    taskt.pop();
  }
  long long int res = 0;
  for (int i = 1; i <= n; i++) {
    if (takahashi[i] < aoki[i]) {
      res = (aoki[i] + takahashi[i]) / 2;
    }
  }
  cout << res;
}
