#include <bits/stdc++.h>
using namespace std;
vector<int> to[100005];
int n;
vector<int> dist;
void dfs(int v, int s = 0, int p = -1) {
  dist[v] = s;
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u, s + 1, v);
  }
}
vector<int> calcDist(int i) {
  dist = vector<int>(n);
  dfs(i);
  return dist;
}
int u, v;
int main() {
  cin >> n >> u >> v;
  --u;
  --v;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  int mx = 0;
  vector<int> A = calcDist(v);
  vector<int> T = calcDist(u);
  for (int i = 0; i < n; ++i) {
    if (A[i] < T[i]) {
      mx = max(mx, T[i]);
    }
  }
  cout << mx << endl;
}
