#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;
vector<int> dist1;
vector<int> dist2;
queue<int> que;
signed main() {
  int N, a, b, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  int ans = 0;
  graph G(N);
  for (int i = 0; i < N; i++) {
    cin >> a >> b;
    a--;
    b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  while (u != v) {
    dist1.assign(N, -1);
    dist1[v] = 0;
    que.push(v);
    while (!que.empty()) {
      int vo = que.front();
      que.pop();
      for (int nv : G[vo]) {
        if (dist1[nv] != -1) continue;
        dist1[nv] = dist1[vo] + 1;
        que.push(nv);
      }
    }
    dist2.assign(N, -1);
    dist2[u] = 0;
    que.push(u);
    while (!que.empty()) {
      int uo = que.front();
      que.pop();
      for (int nv : G[uo]) {
        if (dist2[nv] != -1) continue;
        dist2[nv] = dist2[uo] + 1;
        que.push(nv);
      }
    }
    int tmp = dist1.at(u);
    bool t = true;
    for (int i = 0; i < N; i++) {
      if (dist1.at(i) == tmp + 1) {
        u = i;
        t = false;
        break;
      }
    }
    if (t) {
      for (int i = 0; i < N; i++) {
        if (dist1.at(i) == tmp - 1) {
          u = i;
          break;
        }
      }
    }
    t = true;
    tmp = dist2.at(v);
    for (int i = 0; i < N; i++) {
      if (dist2.at(i) == tmp - 1) {
        v = i;
        t = false;
        ans++;
        break;
      }
    }
    if (t) {
      for (int i = 0; i < N; i++) {
        if (dist2.at(i) == tmp + 1) {
          v = i;
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}
