#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int n;
vector<int> to[100005];
vector<int> dist;

// DFS
void dfs(int t, int d=0, int p=-1) {
  dist[t] = d;
  for (int u: to[t]) {
    if (u == p) continue;
    dfs(u, d + 1, t);
  }
}

vector<int> calcDist(int s) {
  dist = vector<int>(n);
  dfs(s);
  return dist;
}

int main() {
  int u, v;
  cin >> n >> u >> v;
  u--; v--;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<int> distU = calcDist(u);
  vector<int> distV = calcDist(v);

  int mx = 0;
  rep(i, n) {
    if (distU[i] < distV[i]) {
      mx = max(mx, distV[i]);
    }
  }

  cout << mx - 1 << endl;
  return 0;
}
