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