#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int, int>>;
const int INF = 2e5;
const int N = 1e5 + 4;
vi adj[N];
int da[N], dt[N];
void dfs(int u, int p) {
  for (int v : adj[u])
    if (v != p) {
      if (da[v] == INF) {
        da[v] = da[u] + 1;
        dfs(v, u);
      }
    }
}
int walk(int u) {
  queue<ii> q;
  q.push({u, 0});
  int ret = 0;
  while (!q.empty()) {
    int v, d;
    tie(v, d) = q.front();
    q.pop();
    d++;
    for (int x : adj[v]) {
      if (d >= da[x])
        ret = max(ret, da[x]);
      else
        q.push({x, d});
    }
  }
  return ret;
}
int main() {
  int n, 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);
  }
  for (int i = 1; i <= n; i++) da[i] = INF;
  da[v] = 0;
  dfs(v, 0);
  int ans = walk(u);
  printf("%d\n", ans);
}
