#include <bits/stdc++.h>
using namespace std;
template <class U, class V>
istream& operator>>(istream& in, pair<U, V>& pr) {
  return in >> pr.first >> pr.second;
}
void io_init() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
};
int main(int argc, char** argv) {
  io_init();
  int N, T, A;
  cin >> N >> T >> A;
  T--;
  A--;
  vector<vector<int> > Edges(N);
  for (auto i = (0); i != (N - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    Edges[a].push_back(b);
    Edges[b].push_back(a);
  }
  queue<int> bfsQ;
  vector<int> DistA(N, -1);
  auto Visit = [&](int node, int dist) {
    if (DistA[node] < 0) {
      DistA[node] = dist;
      bfsQ.push(node);
    }
  };
  Visit(A, 0);
  while (!bfsQ.empty()) {
    int node = bfsQ.front();
    bfsQ.pop();
    for (int next : Edges[node]) Visit(next, DistA[node] + 1);
  }
  cout << *max_element(DistA.begin(), DistA.end()) - 1 << '\n';
  return 0;
};
