#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void dfs(const vector<vector<int>>& graph, vector<int>& dist, int node) {
  for (int i = (int)0; i < (int)graph[node].size(); ++i) {
    if (dist[graph[node][i]] >= 0) continue;
    dist[graph[node][i]] = dist[node] + 1;
    dfs(graph, dist, graph[node][i]);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, U, V;
  cin >> N >> U >> V;
  int A, B;
  vector<vector<int>> graph(N);
  for (int i = (int)0; i < (int)N - 1; ++i) {
    cin >> A >> B;
    --A, --B;
    graph[A].push_back(B);
    graph[B].push_back(A);
  }
  vector<int> dist1(N, -1);
  dist1[0] = 0;
  dfs(graph, dist1, 0);
  int max_node = -1;
  int max_dist = -1;
  for (int i = (int)0; i < (int)N; ++i) {
    if (max_dist < dist1[i]) {
      max_node = i;
      max_dist = dist1[i];
    }
  }
  vector<int> dist2(N, -1);
  dist2[max_node] = 0;
  dfs(graph, dist2, max_node);
  int ans = -1;
  for (int i = (int)0; i < (int)N; ++i) {
    ans = max(ans, dist2[i]);
  }
  cout << ans - 1 << endl;
  return 0;
}
