#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7LL;
const int INF = 2e9;
int N, u, v;
vector<int> T[100001];
int S[100001][2];
void dfs(int a, int who, int step) {
  if (!who && step >= S[a][1]) return;
  if (who && S[a][who] > 0) return;
  S[a][who] = step;
  for (int i = 0; i < T[a].size(); ++i) {
    int j = T[a][i];
    if (who && (j == v)) continue;
    if (!who && (j == u)) continue;
    dfs(j, who, step + 1);
  }
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> u >> v;
  u--;
  v--;
  int a, b;
  for (int i = 0; i < N - 1; ++i) {
    cin >> a >> b;
    a--;
    b--;
    T[a].push_back(b);
    T[b].push_back(a);
  }
  dfs(v, 1, 0);
  dfs(u, 0, 0);
  int mx = 0;
  for (int i = 0; i < N; ++i) {
    int s = 0;
    for (int j = 0; j < 2; ++j) {
      s += S[i][j];
    }
    mx = max(s / 2, mx);
  }
  cout << mx << "\n";
  return 0;
}
