#include <bits/stdc++.h>
using namespace std;
bool find_path(vector<vector<int>> &E, int s, int g, int p, vector<int> &path) {
  if (s == g) {
    path.push_back(s);
    return true;
  }
  for (int t : E[s]) {
    if (t == p) continue;
    if (find_path(E, t, g, s, path)) {
      path.push_back(s);
      return true;
    }
  }
  return false;
}
int dfs(vector<vector<int>> &E, int v, int p, int d) {
  int ret = d;
  for (int u : E[v]) {
    if (u == p) continue;
    ret = max(ret, dfs(E, u, v, d + 1));
  }
  return ret;
}
int main(void) {
  int N, U, V;
  cin >> N >> U >> V, U--, V--;
  vector<vector<int>> E(N);
  for (int i = 0; i < N - 1; i++) {
    int A, B;
    cin >> A >> B, A--, B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }
  vector<int> path;
  find_path(E, V, U, -1, path);
  int pd = path.size() - 1;
  int d = (pd - 1) / 2;
  int r = path[d];
  int z = path[d + 1];
  int dest = dfs(E, r, z, 0);
  if (dest == 0) {
    cout << pd / 2 << endl;
  } else {
    cout << dest + d << endl;
  }
}
