#include <bits/stdc++.h>
using namespace std;
vector<int> G[10500];
int dist[2][10500] = {};
int ans = 0;
void DFS(int node, int parent, int man) {
  for (auto it : G[node]) {
    if (it != parent) {
      dist[man][it] = dist[man][node] + 1;
      DFS(it, node, man);
    }
  }
}
int main() {
  int n, v, u;
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  DFS(u, -1, 0);
  DFS(v, -1, 1);
  for (int i = 1; i <= n; i++) {
    if (dist[0][i] < dist[1][i]) {
      ans = max(ans, dist[1][i] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
