#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
int n, u, v;
vector<vector<int>> tree;
int ans = 0;
void dfs(int now = v, int p = -1, int dist = 0) {
  chmax(ans, dist);
  for (int i : tree[now]) {
    if (i == p) continue;
    dfs(i, now, dist + 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> u >> v;
  u--;
  v--;
  tree.resize(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  dfs();
  cout << ans - 1 << endl;
}
