#include <bits/stdc++.h>
using namespace std;
long long zeroes(long long n) {
  if (n % 2 || n < 10) return 0;
  long long tmp = n;
  long long res = 0;
  long long power = 0;
  long long max = 1;
  while (tmp >= 10) {
    ++power;
    max *= 10;
    tmp /= 10;
  }
  max *= tmp;
  for (int i = 0; i < power; ++i) {
    res += (power - i) * tmp;
    tmp *= (9 + (i > 0));
  }
  return res + zeroes(n - max);
}
void dfs_a(int v, int turn, const vector<vector<int>>& graph,
           vector<int>& aoki) {
  if (aoki[v] >= 0) return;
  aoki[v] = turn++;
  for (auto u : graph[v]) dfs_a(u, turn, graph, aoki);
}
void dfs_t(int v, int turn, const vector<vector<int>>& graph,
           const vector<int>& aoki, vector<int>& taka) {
  if (taka[v] >= 0 || aoki[v] <= turn) return;
  taka[v] = turn++;
  for (auto u : graph[v]) dfs_t(u, turn, graph, aoki, taka);
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  --u;
  --v;
  vector<vector<int>> graph(n);
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  vector<int> aoki(n, -1);
  vector<int> taka(n, -1);
  dfs_a(v, 0, graph, aoki);
  dfs_t(u, 0, graph, aoki, taka);
  int max = 0;
  for (int i = 0; i < n; ++i) {
    if (taka[i] >= 0 && aoki[i] > max) max = aoki[i];
  }
  if (max) max - 1;
  cout << max << endl;
  return 0;
}
