#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const long long INF = 0x3f3f3f3f;
const long long maxn = 1e5 + 5;
const double pi = acos(-1.0);
using namespace std;
long long n, m;
int dist[maxn], head[maxn];
bool vis[maxn];
struct code {
  int to, w, next;
} edge[maxn];
struct node {
  int to, w;
  bool operator<(const node &x) const { return w > x.w; }
};
priority_queue<node> q;
int cnt;
void intn() {
  cnt = 0;
  memset(head, -1, sizeof(head));
  memset(vis, false, sizeof(vis));
  memset(dist, INF, sizeof(dist));
}
void add(int u, int v, int w) {
  cnt++;
  edge[cnt].to = v;
  edge[cnt].w = w;
  edge[cnt].next = head[u];
  head[u] = cnt;
}
void dijkstra(int u) {
  dist[u] = 0;
  q.push(node{u, dist[u]});
  while (!q.empty()) {
    node x = q.top();
    q.pop();
    if (vis[x.to]) continue;
    vis[x.to] = true;
    for (int i = head[x.to]; i != -1; i = edge[i].next) {
      int v = edge[i].to;
      if (dist[v] > dist[x.to] + edge[i].w) {
        dist[v] = dist[x.to] + edge[i].w;
        q.push(node{v, dist[v]});
      }
    }
  }
}
int main() {
  int n, x, y;
  cin >> n >> x >> y;
  if (x == y)
    cout << "0" << endl;
  else {
    intn();
    n--;
    while (n--) {
      long long u, v, w;
      scanf("%lld%lld", &u, &v);
      add(u, v, 1);
      add(v, u, 1);
    }
    dijkstra(x);
    long long res = dist[y];
    if (res % 2 == 0)
      cout << res / 2 << endl;
    else if (res == 1 && abs(x - y) == 1)
      cout << "0" << endl;
    else
      cout << res / 2 + 1 << endl;
  }
}
