#include <bits/stdc++.h>
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double eps = 0.000000001;
using namespace std;
vector<long long> edge[200000];
long long f[200000];
long long depth[200000];
long long ans;
void bfs(long long now_e, long long dep) {
  for (long long i = 0; (i) < (edge[now_e].size()); ++(i)) {
    long long next_e = edge[now_e][i];
    if (depth[next_e] > 0) continue;
    depth[next_e] = dep + 1;
    bfs(next_e, dep + 1);
  }
}
void bfs2(long long now_e, long long te) {
  for (long long i = 0; (i) < (edge[now_e].size()); ++(i)) {
    long long next_e = edge[now_e][i];
    if (depth[next_e] == te + 2) ans = max(ans, te + 1);
    if (depth[next_e] < te + 3) continue;
    ans = max(ans, te + 1);
    bfs2(next_e, te + 1);
  }
}
signed main() {
  ans = -100;
  long long n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (long long i = 0; (i) < (n - 1); ++(i)) {
    long long a1, b1;
    cin >> a1 >> b1;
    edge[a1 - 1].push_back(b1 - 1);
    edge[b1 - 1].push_back(a1 - 1);
  }
  depth[v] = 1;
  bfs(v, 1);
  ans = (long long)0;
  bfs2(u, 0);
  cout << ans << endl;
  return 0;
}
