#include <bits/stdc++.h>
using namespace std;
const int NMAX = 1e5;
bool vis[NMAX];
int maxx, tmp;
vector<int> g[NMAX];
void dfs(int k, int lg) {
  if (lg > maxx) {
    maxx = lg;
    tmp = k;
  }
  vis[k] = 1;
  for (int i = 0; i < g[k].size(); i++)
    if (vis[g[k][i]] == 0) dfs(g[k][i], lg + 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 1);
  memset(vis, 0, sizeof(vis));
  dfs(tmp, 1);
  cout << maxx - 2 << '\n';
  return 0;
}
