#include <bits/stdc++.h>
using namespace std;
vector<int> adjlist[100005];
int dist[100005];
int s[100005];
int n, u, v;
int main() {
  scanf("%d%d%d", &n, &u, &v);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adjlist[a].push_back(b);
    adjlist[b].push_back(a);
  }
  queue<int> q;
  q.push(u);
  q.push(v);
  memset(dist, -1, sizeof(dist));
  dist[u] = dist[v] = 0;
  s[u] = 0;
  s[v] = 1;
  int ans = 0;
  while (q.size()) {
    int u = q.front();
    q.pop();
    if (s[u] == -1) continue;
    for (auto v : adjlist[u]) {
      if (dist[v] == -1) {
        dist[v] = dist[u] + 1;
        s[v] = s[u];
        q.push(v);
      } else if (s[v] != s[u] && dist[v] == dist[u] + 1) {
        s[v] = -1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (s[i] <= 0) {
      ans = max(ans, dist[i]);
    }
  }
  printf("%d", ans);
}
