#include <bits/stdc++.h>
using namespace std;
const long long INF = 1000000000000005;
const int maxn = 1e6 + 5;
long long n, m, p;
long long ss, ee;
int head[maxn];
long long cnt = 0;
vector<int> v[maxn];
int deep[maxn];
void DFS(int u, int fa) {
  deep[u] = deep[fa] + 1;
  int sz = v[u].size();
  for (int i = 0; i < sz; i++) {
    int e = v[u][i];
    if (e == fa) continue;
    DFS(e, u);
  }
}
int get_dia() {
  int S = 0;
  DFS(1, 0);
  for (int i = 1; i <= n; i++) {
    if (deep[S] < deep[i]) S = i;
  }
  DFS(S, 0);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(deep[i], ans);
  }
  return ans;
}
int main() {
  memset(deep, -1, sizeof(deep));
  scanf("%lld%lld%lld", &n, &ss, &ee);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  int dis = get_dia();
  printf("%d\n", dis - 1);
  return 0;
}
