#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1000000;
int main() {
  long long n, u, v;
  cin >> n >> u >> v;
  long long res = 0;
  vector<vector<int>> G(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }
  vector<int> dista(n, -1);
  vector<int> distb(n, -1);
  dista[u - 1] = 0;
  distb[v - 1] = 0;
  queue<int> quea;
  queue<int> queb;
  quea.push(u - 1);
  queb.push(v - 1);
  while (!quea.empty()) {
    int p = quea.front();
    quea.pop();
    for (int nv : G[p]) {
      if (dista[nv] != -1) continue;
      dista[nv] = dista[p] + 1;
      quea.push(nv);
    }
  }
  while (!queb.empty()) {
    int p = queb.front();
    queb.pop();
    for (int nv : G[p]) {
      if (distb[nv] != -1) continue;
      distb[nv] = distb[p] + 1;
      queb.push(nv);
    }
  }
  int x = u - 1, y = v - 1;
  bool flag = 1;
  while (flag) {
    int max_distb = 0;
    for (int nv : G[x]) {
      if (distb[nv] >= max_distb) {
        max_distb = distb[nv];
        x = nv;
      }
    }
    if (x == y) {
      flag = 0;
      break;
    }
    int min_dista = n;
    for (int nv : G[y]) {
      if (dista[nv] <= min_dista) {
        min_dista = dista[nv];
        y = nv;
      }
    }
    res++;
    if (x == y) {
      flag = 0;
      break;
    }
  }
  cout << res << endl;
}
