#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 2;
vector<int> adj[MX];
int seen[MX];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  queue<int> q1({u}), q2({v});
  seen[u] = 1;
  seen[v] = 2;
  int tm = 0;
  while (1) {
    int s = q1.size();
    while (s--) {
      int t = q1.front();
      q1.pop();
      for (int a : adj[t]) {
        if (!seen[a]) {
          seen[a] = 1;
          q1.push(a);
        }
      }
    }
    s = q2.size();
    if (!s) {
      return !(cout << tm - 2);
    }
    while (s--) {
      int t = q2.front();
      q2.pop();
      for (int a : adj[t]) {
        if (seen[a] <= 1) {
          seen[a] = 2;
          q2.push(a);
        }
      }
    }
    tm++;
  }
}
