#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
Graph G(100100);
bool isgoal = false;
int goal;
deque<int> deq;
int d[100100];
void dfs_(int v, int par) {
  if (isgoal) return;
  deq.push_back(v);
  if (v == goal) {
    isgoal = true;
    return;
  };
  for (int i = 0; i < G[v].size(); i++) {
    int nv = G[v][i];
    if (nv == par) continue;
    dfs_(nv, v);
  }
  if (isgoal) return;
  deq.pop_back();
}
void dfs(int v, int par, int proh) {
  if (v == proh) return;
  for (int nv : G[v]) {
    if (nv == par) continue;
    d[nv] = d[v] + 1;
    dfs(nv, v, proh);
  }
}
int main() {
  int n, u, v, res, proh;
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i = 0; (i) < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  goal = u;
  dfs_(v, -1);
  for (int i = 0; (i) < (int)((deq.size() + 1) / 2 + 1); i++) {
    proh = deq.front();
    deq.pop_front();
  }
  dfs(v, -1, proh);
  for (int i = 0; (i) < (int)(n); i++) {
    if (res < d[i]) {
      res = d[i];
      goal = i;
    }
  }
  fill(d, d + n, 0);
  dfs(u, -1, -1);
  cout << d[goal] - 1 << endl;
}
