#include <bits/stdc++.h>
using namespace std;
long long K = 1000000007;
int MAX = 100000;
int INF = MAX + 1;
vector<int> Dis(MAX);
vector<int> Dis2(MAX);
vector<vector<int>> Way(MAX, vector<int>(0));
int main() {
  int N;
  int U, V;
  cin >> N >> U >> V;
  U--;
  V--;
  vector<vector<int>> Tree(N - 1, vector<int>(2));
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    Tree[i][0] = A;
    Tree[i][1] = B;
    Way[A].push_back(B);
    Way[B].push_back(A);
  }
  for (int i = 0; i < N; i++) Dis[i] = INF;
  Dis[V] = 0;
  while (true) {
    bool update = false;
    for (int i = 0; i < N - 1; i++) {
      if (Dis[Tree[i][0]] != INF && Dis[Tree[i][1]] > Dis[Tree[i][0]] + 1) {
        Dis[Tree[i][1]] = Dis[Tree[i][0]] + 1;
        update = true;
      }
      if (Dis[Tree[i][1]] != INF && Dis[Tree[i][0]] > Dis[Tree[i][1]] + 1) {
        Dis[Tree[i][0]] = Dis[Tree[i][1]] + 1;
        update = true;
      }
    }
    if (!update) break;
  }
  for (int i = 0; i < N; i++) Dis2[i] = INF;
  Dis2[U] = 0;
  while (true) {
    bool update = false;
    for (int i = 0; i < N - 1; i++) {
      if (Dis2[Tree[i][0]] != INF && Dis2[Tree[i][1]] > Dis2[Tree[i][0]] + 1) {
        Dis2[Tree[i][1]] = Dis2[Tree[i][0]] + 1;
        update = true;
      }
      if (Dis2[Tree[i][1]] != INF && Dis2[Tree[i][0]] > Dis2[Tree[i][1]] + 1) {
        Dis2[Tree[i][0]] = Dis2[Tree[i][1]] + 1;
        update = true;
      }
    }
    if (!update) break;
  }
  int Max = 0;
  for (int i = 0; i < N; i++) {
    if (Dis[i] > Dis2[i]) {
      Max = max(Max, Dis[i]);
    }
  }
  cout << Max - 1;
}
