#include <bits/stdc++.h>
using namespace std;
const long long int maxs = 1e5;
long long int n, a, b;
std::vector<long long int> Tree[maxs];
long long int dist[2][maxs];
void go(long long int s, long long int p, long long int ind) {
  dist[ind][s] = dist[ind][p] + 1;
  for (auto d : Tree[s]) {
    if (d != p) go(d, s, ind);
  }
}
int main() {
  cin >> n >> a >> b;
  for (long long int i = 0; i < n - 1; i++) {
    long long int s, d;
    cin >> s >> d;
    Tree[s].push_back(d);
    Tree[d].push_back(s);
  }
  dist[0][0] = dist[1][0] = -1;
  go(a, 0, 0);
  go(b, 0, 1);
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    if (dist[0][i] < dist[1][i]) {
      ans = max(ans, dist[1][i] - 1);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}
