#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
int prof[100005];
int haut[100005];
int parent[100005];
void initialiser() {
  for (int i = 0; i < 100005; i++) {
    prof[i] = 0;
    haut[i] = 0;
    parent[i] = -1;
  }
}
int N;
void enraciner(int sommet) {
  haut[sommet] = 1;
  for (int i = 0; i < (int)adj[sommet].size(); i++) {
    int s = adj[sommet][i];
    if (s != parent[sommet]) {
      parent[s] = sommet;
      prof[s] = 1 + prof[sommet];
      enraciner(s);
      haut[sommet] = max(haut[sommet], 1 + haut[s]);
    }
  }
}
int main() {
  initialiser();
  int u, v;
  scanf("%d %d %d", &N, &u, &v);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  enraciner(v);
  int ans = 0;
  int pu = prof[u];
  int pv = prof[v];
  int m = (pu - pv - 1) / 2;
  pu -= m;
  pv += m;
  ans += m;
  for (int i = 0; i < m; i++) u = parent[u];
  int mx = 0;
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int s = adj[u][i];
    if (s != parent[u]) {
      mx = max(mx, haut[s]);
    }
  }
  ans += mx;
  int last = (pu - pv) / 2;
  ans += last;
  printf("%d", ans);
}
