#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
static const int N = 100;
void bfs(int s, vector<int>& D, vector<vector<int> > M);
int n;
int main() {
  int T, A;
  cin >> n >> T >> A;
  T--;
  A--;
  vector<vector<int> > M(n);
  int a, b;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    M[a].push_back(b);
    M[b].push_back(a);
  }
  vector<int> T_dis(N, -1);
  vector<int> A_dis(N, -1);
  bfs(T, T_dis, M);
  bfs(A, A_dis, M);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (T_dis[i] < A_dis[i]) {
      ans = max(ans, T_dis[i] + max(0, A_dis[i] - T_dis[i] - 1));
    }
  }
  cout << ans << '\n';
}
void bfs(int s, vector<int>& D, vector<vector<int> > M) {
  queue<int> q;
  D[s] = 0;
  q.push(s);
  int u;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (int i = 0; i < M[u].size(); i++) {
      int cur_node = M[u][i];
      if (D[cur_node] != -1) continue;
      D[cur_node] = D[u] + 1;
      q.push(cur_node);
    }
  }
}
