#include <bits/stdc++.h>
using namespace std;
int n, u, v, a, b, r;
vector<int> t[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; i++) {
    cin >> a;
    cin >> b;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  int prev = -1;
  while (u != v) {
    if (t[u][0] != v)
      u = t[u][0];
    else {
      if (t[u].size() == 1)
        u = t[u][0];
      else
        u = t[u][1];
    }
    if (u == v) break;
    if (t[v][0] != prev) {
      prev = v;
      v = t[v][0];
    } else {
      prev = v;
      v = t[v][1];
    }
    r++;
  }
  cout << r;
}
