#include <bits/stdc++.h>
using namespace std;
void dfs(int parent, int current, const vector<vector<int> > nodes,
         int distances[], int distance = 0) {
  distances[current] = distance;
  for (int to : nodes[current]) {
    if (to == parent) {
      continue;
    }
    dfs(current, to, nodes, distances, distance + 1);
  }
}
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<vector<int> > nodes(N);
  for (int i = 0; i < (int)(N - 1); i++) {
    int from, to;
    cin >> from >> to;
    from--;
    to--;
    nodes[from].push_back(to);
    nodes[to].push_back(from);
  }
  int distance_from_aoki[N], distance_from_takahashi[N];
  memset(distance_from_aoki, 0, sizeof(distance_from_aoki));
  memset(distance_from_takahashi, 0, sizeof(distance_from_takahashi));
  dfs(-1, v, nodes, distance_from_aoki);
  int ans = 0;
  for (int i = 0; i < (int)(N); i++) {
    if (distance_from_takahashi[i] < distance_from_aoki[i]) {
      ans = max(ans, distance_from_aoki[i] - 1);
    }
  }
  cout << ans << endl;
}
