#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323846264;
const int mod = 1000000007;
int main() {
  int n, u, v, du;
  cin >> n >> u >> v;
  vector<int> a(n), b(n), used(n + 1, 0), depth(n + 1, mod), used2(n + 1, 0);
  vector<vector<int> > g(n + 1, vector<int>());
  for (int i = (1); i < (n); ++i) {
    cin >> a[i - 1] >> b[i - 1];
    g[a[i - 1]].push_back(b[i - 1]);
    g[b[i - 1]].push_back(a[i - 1]);
  }
  queue<int> q;
  q.push(u);
  used[u] = 1;
  while (q.size()) {
    auto nw = q.front();
    q.pop();
    for (auto x : g[nw]) {
      if (used[x] || x == v) continue;
      q.push(x);
      used[x] = 1;
    }
  }
  q.push(v);
  depth[v] = 0;
  while (q.size()) {
    auto nw = q.front();
    q.pop();
    for (auto x : g[nw]) {
      if (used[x] == 0 || depth[x] != mod) continue;
      q.push(x);
      depth[x] = depth[nw] + 1;
      if (x == u) du = depth[x];
    }
  }
  int th = du / 2, ans = 1;
  q.push(u);
  used2[u] = 1;
  while (q.size()) {
    auto nw = q.front();
    q.pop();
    for (auto x : g[nw]) {
      if (used[x] == 0 || depth[x] <= th || used2[x] != 0) continue;
      q.push(x);
      used2[x] = used2[nw] + 1;
      ans = max(ans, used2[x]);
    }
  }
  cout << ans - 1 << endl;
}
