#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int head[maxn], ver[maxn], nxt[maxn], tot, edge[maxn];
bool vis[maxn];
int d[maxn], ans;
void add(int x, int y) {
  ver[++tot] = y;
  edge[tot] = 1;
  nxt[tot] = head[x];
  head[x] = tot;
}
void dp(int x) {
  vis[x] = 1;
  for (int i = head[x]; i; i = nxt[i]) {
    int y = ver[i];
    if (vis[y]) continue;
    dp(y);
    ans = max(ans, d[x] + d[y] + edge[i]);
    d[x] = max(d[x], d[y] + edge[i]);
  }
}
int main() {
  int n, u, v;
  memset(vis, 0, sizeof(vis));
  cin >> n >> u >> v;
  ans = 0;
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    cin >> x >> y;
    add(x, y);
    add(y, x);
  }
  dp(v);
  cout << ans - 1 << endl;
  return 0;
}
