#include <bits/stdc++.h>
using namespace std;
int D[100005][2];
vector<int> Graph[100005];
void dfs(int e, int a, int d, int id) {
  D[e][id] = d;
  for (int i : Graph[e]) {
    if (i != a) dfs(i, e, d + 1, id);
  }
}
int main() {
  int N, u, v;
  cin >> N >> u >> v;
  int p, q;
  for (int i = 0; i < N - 1; ++i) {
    cin >> p >> q;
    Graph[p].push_back(q);
    Graph[q].push_back(p);
  }
  dfs(u, u, 0, 0);
  dfs(v, v, 0, 1);
  int ans = 0;
  for (int a = 0; a < N; ++a) {
    if (D[a][0] < D[a][1]) {
      ans = max(ans, D[a][1] - 1);
    }
  }
  cout << ans << endl;
}
