#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n) {
    for (int i = 0; i < n; i++) par[i] = i;
  }
  int find(int x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    int rx = find(x);
    int ry = find(y);
    if (rx != ry) par[rx] = ry;
  }
  bool same(int x, int y) { return find(x) == find(y); }
};
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  int a[n];
  int b[n];
  vector<set<int> > tree(n);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    tree[a[i]].insert(b[i]);
    tree[b[i]].insert(a[i]);
  }
  stack<int> que;
  vector<int> distance(n, 1 << 30);
  for (int i = 0; i < n; i++) {
    if (tree[i].size() == 1) {
      distance[i] = 0;
      que.push(i);
    }
  }
  while (!que.empty()) {
    int i = que.top();
    que.pop();
    for (int j : tree[i]) {
      if (distance[j] > distance[i] + 1) {
        distance[j] = distance[i] + 1;
        que.push(j);
      }
    }
  }
  queue<int> queu;
  UnionFind unif(n);
  queu.push(v);
  vector<int> point(n, -1);
  point[v] = 0;
  while (!queu.empty()) {
    int i = queu.front();
    queu.pop();
    for (int j : tree[i]) {
      if (point[j] == -1) {
        point[j] = point[i] + 1;
        queu.push(j);
      }
    }
  }
  int uTov = point[u];
  int nige = distance[u];
  int ans = 0;
  bool takahasi = true;
  int tak = u;
  while (uTov > 0) {
    if (takahasi) {
      if (uTov > 2) {
        int tmptak = tak;
        for (int j : tree[tak]) {
          if (point[j] < point[tak]) {
            tmptak = j;
          }
        }
        tak = tmptak;
        nige++;
        uTov--;
      } else if (nige > 0) {
        int tmp = 0;
        int tmptak = tak;
        for (int j : tree[tak]) {
          if (distance[j] > tmp && point[j] > point[tak]) {
            tmptak = j;
            tmp = distance[j];
          }
        }
        if (tmptak == tak) {
          for (int j : tree[tak]) {
            if (point[j] > point[tak]) {
              tmptak = j;
              break;
            }
          }
        }
        tak = tmptak;
        nige = distance[tak];
        uTov++;
      } else {
        int tmptak = 0;
        for (int j : tree[tak]) {
          if (point[j] < point[tak]) {
            tmptak = j;
          }
        }
        tak = tmptak;
        nige++;
        uTov--;
      }
    } else {
      ans++;
      uTov--;
    }
    takahasi = !takahasi;
  }
  cout << ans << endl;
}
