#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const int N = 100001;
vector<int> graph[N];
int depth[N], longest[N], visit[N], parent[N];
int dfs(int now, int d) {
  if (visit[now]) return 0;
  depth[now] = d;
  visit[now] = 1;
  int dd = 0;
  for (auto elem : graph[now]) {
    if (!visit[elem]) parent[elem] = now;
    dd = max(dd, dfs(elem, d + 1) + 1);
  }
  longest[now] = dd;
  return dd;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  dfs(v, 0);
  int now = u, ans = 0;
  for (int i = 0; i < (depth[u] + 1) / 2; i++) {
    int tmp = i + longest[now] - 1 + (depth[now] - i * 2) / 2;
    ans = max(ans, tmp);
    now = parent[now];
  }
  cout << ans << endl;
  return 0;
}
