#include <bits/stdc++.h>
using namespace std;
void solve();
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  for (int i = 1; i <= t; ++i) solve();
  cerr << "Time taken: " << ((clock() * 1000) / CLOCKS_PER_SEC) << "ms\n";
}
const int N = 1e5 + 2;
int a[N], n, u, v;
std::vector<int> adj[N];
void dfs(int node, int pre, int dis) {
  a[node] = dis;
  for (auto i : adj[node]) {
    if (i != pre) {
      dfs(i, node, dis + 1);
    }
  }
}
int ans = 0;
void dfs2(int node, int pre, int dis) {
  ans = max(ans, dis + (a[node] - dis) / 2);
  for (auto i : adj[node]) {
    if (i != pre and (dis + 1) < a[i]) {
      dfs2(i, node, dis + 1);
    }
  }
}
void solve() {
  cin >> n >> u >> v;
  for (int i = 0; i < n - 1; ++i) {
    int p, q;
    cin >> p >> q;
    adj[p].push_back(q);
    adj[q].push_back(p);
  }
  dfs(v, -1, 0);
  dfs2(u, -1, 0);
  cout << ans << '\n';
}
