#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> a;
vector<int> t;
int res = 0;
map<int, set<int>> g;
void dfs(int cur, int dist) {
  if (a[cur] <= dist) return;
  a[cur] = dist;
  for (int path : g[cur]) {
    dfs(path, dist + 1);
  }
}
void dfs2(int cur, int dist) {
  if (a[cur] <= dist) {
    res = max(a[cur], res);
    return;
  }
  for (int path : g[cur]) {
    dfs2(path, dist + 1);
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; ++i) {
    int e1, e2;
    cin >> e1 >> e2;
    g[e1].insert(e2);
    g[e2].insert(e1);
  }
  a.resize(n + 1, n + 1);
  t.resize(n + 1);
  dfs(v, 0);
  dfs2(u, 0);
  cout << res << "\n";
  return 0;
}
