#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<int> a;
vector<int> t;
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 (t[cur] <= dist) return;
  if (a[cur] == dist) {
    t[cur] = a[cur];
    return;
  }
  if (a[cur] < dist) return;
  t[cur] = dist;
  for (int path : g[cur]) {
    dfs2(path, dist + 1);
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 1; i < n; ++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, n + 1);
  dfs(v, 0);
  for (int path : g[u]) {
    dfs2(path, 1);
  }
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    if (t[i] <= n) {
      res = max(res, a[i] - ((a[i] + t[i]) % 2));
    }
  }
  cout << res << "\n";
  return 0;
}
