#include <bits/stdc++.h>
using namespace std;

void dfs(const vector<vector<int>> &to, vector<int> &d, int current) {
  for (auto next : to.at(current)) {
    if (d.at(next) == -1) {
      d.at(next) = d.at(current) + 1;
      dfs(to, d, next);
    }
  }
}

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  vector<vector<int>> to(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }
  vector<int> du(n, -1), dv(n, -1);
  du.at(u) = 0;
  dv.at(v) = 0;
  dfs(to, du, u);
  dfs(to, dv, v);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (du.at(i) < dv.at(i)) ans = max(ans, dv.at(i) - 1);
  }
  cout << ans << endl;
}
