#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
long long n;
vector<vector<long long> > e;
vector<long long> p;
vector<long long> level;
vector<long long> deepest;
long long dfs(long long v, long long l, long long lev) {
  p[v] = l;
  level[v] = lev;
  long long depth = 0;
  for (auto& u : e[v]) {
    if (l != u) depth = max(depth, dfs(u, v, lev + 1));
  }
  return deepest[v] = depth + 1;
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  long long u, v;
  cin >> n >> u >> v;
  --u;
  --v;
  e.resize(n);
  p.resize(n);
  level.resize(n);
  deepest.resize(n);
  for (long long i = 0; i < long long(n - 1); ++i) {
    long long a, b;
    cin >> a >> b;
    --a;
    --b;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  dfs(v, v, 0);
  if (level[u] == 1 && deepest[u] == 1) {
    cout << 0 << endl;
    return 0;
  }
  long long ans = 0;
  long long up = (level[u] - 1) / 2;
  for (long long i = 0; i < long long(up); ++i) {
    u = p[u];
    ans++;
  }
  cout << max(1ll, ans + deepest[u] - 1) << endl;
}
