#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
vector<vector<int>> edge(100100);
int n, u, v;
bool visitedt[100100];
int main() {
  cin >> n >> u >> v;
  --u;
  --v;
  for (int i = 0; i <= n - 2; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  queue<pair<int, int>> que;
  que.push(make_pair(u, v));
  int ref = 0;
  while (1) {
    auto now = que.front();
    que.pop();
    if (visitedt[now.first]) break;
    if (now.first == now.second) {
      cout << ref << endl;
      return 0;
    }
    ++ref;
    visitedt[now.first] = true;
    for (auto x : edge[now.first]) {
      if (x == now.second) {
        cout << ref << endl;
        return 0;
      }
      for (auto y : edge[now.second]) {
        que.push(make_pair(x, y));
      }
    }
  }
  cout << ref << endl;
}
