#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> G;
int dist[101010][2];
void dfs(int cur, int pre, int d, int id) {
  dist[cur][id] = d;
  for (const auto next : G[cur]) {
    if (next != pre) {
      dfs(next, cur, d + 1, id);
    }
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(u, u, 0, 0);
  dfs(v, v, 0, 1);
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (dist[i][0] < dist[i][1]) ans = max(ans, dist[i][1] - 1);
  cout << ans;
}
