#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> graph(100001);
vector<int> stepFromV(100001, -1);
int main() {
  int n;
  int u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  if (u == v) {
    cout << 0 << endl;
    return 0;
  }
  queue<int> qu;
  qu.push(v);
  stepFromV[v] = 0;
  while (!qu.empty()) {
    int now = qu.front();
    qu.pop();
    for (int i = 0; i < graph[now].size(); i++) {
      int next = graph[now][i];
      if (stepFromV[next] == -1) {
        stepFromV[next] = stepFromV[now] + 1;
        qu.push(next);
      }
    }
  }
  queue<pair<int, int>> qu2;
  qu2.push(make_pair(u, 0));
  int ans = 0;
  for (int p = 0; p <= 2 * n && !qu2.empty(); p++) {
    int now = (qu2.front()).first;
    int stepnum = (qu2.front()).second;
    qu2.pop();
    for (int i = 0; i < graph[now].size(); i++) {
      int next = graph[now][i];
      if (!(stepFromV[next] == stepnum + 1 || stepFromV[next] == stepnum)) {
        qu2.push(make_pair(next, stepnum + 1));
      } else {
        ans = max(ans, stepFromV[next]);
      }
    }
  }
  cout << ans << endl;
  return 0;
}
