#include <iostream>
#include <vector>
using namespace std;
typedef vector<vector<int>> tree;

void dfs(tree& t, vector<int>& dists, int node, int dist) {
  if (dists[node] < 0) {
    dists[node] = dist;
    for (int next : t[node]) {
      dfs(t, dists, next, dist+1);
    }
  }
}

int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--; v--;
  tree t(n);
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    t[a].push_back(b);
    t[b].push_back(a);
  }
  vector<int> udists(n, -1), vdists(n, -1);
  dfs(t, udists, u, 0);
  dfs(t, vdists, v, 0);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (udists[i] < vdists[i]) {
      if (udists[i] + vdists[i] == 1) continue;
      ans = max(ans, vdists[i]-1);
    }
  }
  cout << ans << endl;
}