#include <bits/stdc++.h>
using namespace std;
int N;
vector<vector<int> > Edges;
vector<pair<pair<int, int>, int> > States;
int dist(int x, int y) {
  queue<int> que;
  que.push(x);
  vector<int> seen(N + 1, -1);
  seen[x] = 0;
  while (!que.empty()) {
    int cur = que.front();
    que.pop();
    for (int e = 0; e < Edges[cur].size(); e++) {
      if (seen[Edges[cur][e]] == -1) {
        que.push(Edges[cur][e]);
        seen[Edges[cur][e]] = seen[cur] + 1;
      }
    }
  }
  return seen[y];
}
void dfs(int x, int y, int cur) {
  States.push_back(make_pair(make_pair(x, y), cur));
  for (int ef = 0; ef < Edges[x].size(); ef++) {
    if (Edges[x][ef] == y) continue;
    for (int es = 0; es < Edges[y].size(); es++) {
      if (dist(Edges[x][ef], y) > dist(Edges[x][ef], Edges[y][es])) {
        bool flag = true;
        for (int si = 0; si < States.size(); si++) {
          if (States[si].first.first == Edges[x][ef] &&
              States[si].first.second == Edges[y][es]) {
            flag = false;
            break;
          }
        }
        if (flag) {
          if (Edges[x][ef] == Edges[y][es]) {
            States.push_back(
                make_pair(make_pair(Edges[x][ef], Edges[y][es]), cur + 1));
          } else {
            dfs(Edges[x][ef], Edges[y][es], cur + 1);
          }
        }
      }
    }
  }
}
int main() {
  int u, v;
  cin >> N >> u >> v;
  Edges.resize(N + 1);
  for (int n = 1; n < N; n++) {
    int a, b;
    cin >> a >> b;
    Edges[a].push_back(b);
    Edges[b].push_back(a);
  }
  dfs(u, v, 0);
  int ans = 0;
  for (int si = 0; si < States.size(); si++) {
    if (ans < States[si].second) {
      ans = States[si].second;
    }
  }
  cout << ans << endl;
  return 0;
}
