#include <bits/stdc++.h>
using namespace std;
bool vis[100010];
int d[100010];
int mx, val;
vector<int> G[100010];
void dfs_deep(int k, int dep) {
  vis[k] = 1;
  d[k] = dep;
  for (auto& i : G[k]) {
    if (!vis[i]) dfs_deep(i, dep + 1);
  }
  mx = max(mx, dep);
}
void dfs_deep2(int k, int dep, int ok_depth) {
  vis[k] = 1;
  mx = max(mx, d[k]);
  bool ii = 1;
  for (auto& i : G[k]) {
    if (!vis[i] && d[i] >= ok_depth) {
      dfs_deep2(i, dep + 1, ok_depth);
      ii = 0;
    }
  }
}
void check(int de, int at, int ok) {
  if (at == ok) {
    val = de;
    return;
  }
  for (auto& i : G[de]) {
    if (d[i] == at - 1) check(i, at - 1, ok);
  }
}
int main() {
  int n, t, a;
  cin >> n >> t >> a;
  t--;
  a--;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    G[--x].push_back(--y);
    G[y].push_back(x);
    vis[i] = 0;
  }
  vis[n - 1] = 0;
  dfs_deep(a, 0);
  int ok_depth = d[t] - (d[t] - 1) / 2;
  check(t, t, ok_depth);
  int ok_v = val;
  for (int i = 0; i < n; i++) {
    if (ok_depth > d[i])
      vis[i] = 1;
    else
      vis[i] = 0;
  }
  mx = 0;
  dfs_deep2(ok_v, ok_depth, ok_depth);
  cout << mx - 1 << endl;
}
