#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 30, Mod = 1e9 + 7;
const long long SQ = 330;
long long n, x, y;
long long dx[N], dy[N];
vector<long long> G[N];
void dfsx(long long v, long long par = 0) {
  for (auto u : G[v])
    if (u != par) dx[u] = dx[v] + 1, dfsx(u, v);
}
void dfsy(long long v, long long par = 0) {
  for (auto u : G[v])
    if (u != par) dy[u] = dy[v] + 1, dfsy(u, v);
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n >> x >> y;
  for (int i = 0; i < n - 1; i++) {
    long long v, u;
    cin >> v >> u;
    G[v].push_back(u);
    G[u].push_back(v);
  }
  dfsx(x);
  dfsy(y);
  long long ans = 0;
  for (int i = 1; i <= n; i++)
    if (dx[i] < dy[i]) ans = max(ans, dy[i]);
  cout << ans - (G[x].size() == 1) << endl;
  return (0);
}
