#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N, u, v;
vector<vector<int>> graph;
vector<int> aoki_dist, taka_dist;
int ans = 0;
void dfs(int node) {
  for (auto nx : graph[node]) {
    if (aoki_dist[nx] != -1) continue;
    aoki_dist[nx] = aoki_dist[node] + 1;
    dfs(nx);
  }
}
void solve(int node, int turn) {
  for (auto nx : graph[node]) {
    if (aoki_dist[nx] == turn) {
      ans = max(ans, turn);
    } else if (aoki_dist[nx] == turn + 1) {
      ans = max(ans, turn + 1);
    } else {
      solve(nx, turn + 1);
    }
  }
}
int main() {
  cin >> N >> u >> v;
  u--, v--;
  graph.resize(N);
  for (int i = 0; i < (N - 1); ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  aoki_dist.resize(N, -1), taka_dist.resize(N, -1);
  aoki_dist[v] = 0;
  dfs(v);
  solve(u, 0);
  cout << ans << endl;
  return 0;
}
