#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int INF = 1e9 + 10;
vector<int> g[maxn];
int du[maxn], dv[maxn];
map<int, vector<int> > mp1, mp2;
void bfs(int u, int v) {
  for (int i = 0; i < maxn; ++i) {
    du[i] = dv[i] = INF;
  }
  du[u] = 0;
  dv[v] = 0;
  queue<int> q;
  q.push(u);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto &w : g[x]) {
      if (du[x] + 1 < du[w]) {
        du[w] = du[x] + 1;
        mp1[du[x] + 1].push_back(w);
        q.push(w);
      }
    }
  }
  q.push(v);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto &w : g[x]) {
      if (dv[x] + 1 < dv[w]) {
        dv[w] = dv[x] + 1;
        mp2[dv[x] + 1].push_back(w);
        q.push(w);
      }
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) {
    sort((g[i]).begin(), (g[i]).end());
  }
  bfs(u, v);
  int ans = 0, f = 0;
  bool end = false;
  while (!end) {
    bool ok = false;
    int aux = u;
    for (auto &x : mp1[du[u] + 1]) {
      if (x != v && binary_search((g[u]).begin(), (g[u]).end(), x)) {
        u = x;
        ok = true;
        break;
      }
    }
    if (du[aux] - 1 >= 0 && !ok) {
      for (auto &x : mp1[du[aux] - 1]) {
        if (x != v && binary_search((g[u]).begin(), (g[u]).end(), x)) {
          u = x;
          ok = true;
          break;
        }
      }
    }
    if (!ok) {
      end = true;
      f = 1;
    }
    ok = false;
    bool cnt = false;
    for (auto &x : mp2[dv[v] + 1]) {
      if (x == u) {
        ok = true;
      }
      if (x == aux) {
        v = x;
        cnt = true;
      }
    }
    if (ok)
      end = true;
    else if (!cnt) {
      for (auto &x : mp2[dv[v] + 1]) {
        if (x != u) {
          v = x;
          break;
        }
      }
    }
    ++ans;
  }
  cout << ans - f << endl;
  return 0;
}
