#include <bits/stdc++.h>
using namespace std;
long long INF = 1e12 + 10;
vector<pair<long long, long long> > pairs;
const long long MAX = long long(1e10) * 300 + 10;
struct edge {
  int to, cost;
};
vector<edge> G[int(1e5 + 1)];
long long d[int(1e5 + 1)];
int S, T, V;
void dijkstra(int s) {
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      que;
  fill(d, d + V, (1000000000LL));
  d[s] = 0;
  que.push(pair<int, int>(0, s));
  while (!que.empty()) {
    pair<int, int> p = que.top();
    que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0; i < G[v].size(); i++) {
      edge e = G[v][i];
      if (d[e.to] > d[v] + e.cost) {
        d[e.to] = d[v] + e.cost;
        que.push(pair<int, int>(d[e.to], e.to));
      }
    }
  }
  return;
}
int main() {
  int ans = 0;
  cin >> V >> T >> S;
  S--;
  T--;
  vector<int> A(V), B(V), C(V);
  for (int i = 0; i < V - 1; i++) {
    cin >> A[i] >> B[i];
    C[i] = 1;
    G[A[i] - 1].push_back((edge){B[i] - 1, C[i]});
    G[B[i] - 1].push_back((edge){A[i] - 1, C[i]});
  }
  dijkstra(S);
  int a = S, b = T;
  while (1) {
    if (a == b) {
      break;
    }
    int next;
    int cost = 1000000;
    for (int i = 0; i < G[a].size(); i++) {
      edge e = G[a][i];
      if (d[e.to] < cost) {
        cost = d[e.to];
        next = e.to;
      }
    }
    a = next;
    if (a == b) {
      break;
    }
    cost = 1000000;
    for (int i = 0; i < G[b].size(); i++) {
      edge e = G[b][i];
      if (d[e.to] < cost) {
        cost = d[e.to];
        next = e.to;
      }
    }
    ans++;
    b = next;
  }
  cout << ans << endl;
  return 0;
}
