#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
vector<bool> seen;
void dfs(Graph G, int u, int v, int turn, int &ans, int i) {
  i++;
  if (u == v) {
    ans = max(ans, turn);
    return;
  }
  seen[v] = true;
  if (i % 2 == 1) {
    for (int next_u : G[u]) {
      dfs(G, next_u, v, turn, ans, i);
    }
  } else {
    turn++;
    for (int next_v : G[v]) {
      if (seen[next_v]) continue;
      dfs(G, u, next_v, turn, ans, i);
    }
  }
}
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  Graph G(N + 1);
  for (int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  seen.assign(N + 1, false);
  int ans = 0;
  dfs(G, u, v, 0, ans, 0);
  cout << ans << endl;
}
