#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e15;
vector<long long> d[100001];
long long K[100001];
int N, u, v;
long long Max = 0;
long long Par[100001];
void dfs(long long x) {
  long long P = d[x].size();
  for (int i = 0; i < P; i++) {
    long long y = d[x].at(i);
    if (K[y] == -1) {
      K[y] = K[x] + 1;
      Par[y] = x;
      dfs(y);
    }
  }
  return;
}
void Sons(long long x) {
  long long P = d[x].size();
  for (int i = 0; i < P; i++) {
    long long y = d[x].at(i);
    if (K[y] == K[x] + 1) {
      Max = max(Max, K[y]);
      Sons(y);
    }
  }
  return;
}
int main() {
  cin >> N >> u >> v;
  for (int i = 0; i < 100001; i++) K[i] = -1;
  K[v] = 0;
  for (int i = 0; i < N - 1; i++) {
    long long A, B;
    cin >> A >> B;
    d[A].push_back(B);
    d[B].push_back(A);
  }
  dfs(v);
  long long A = K[u];
  A = (A - 1) / 2;
  long long t = u;
  for (int i = 0; i < A; i++) t = Par[t];
  Sons(t);
  cout << Max - 1 << endl;
}
