#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n, t, a, d[100010], mx;
vector<long long> g[100010];
long long dfs(long long p, long long nod) {
  for (long long i : g[nod]) {
    if (i != p) {
      d[i] = d[nod] + 1;
      mx = max(mx, d[i]);
      dfs(nod, i);
    }
  }
}
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  cin >> n >> t >> a;
  for (long long i = 1, first, second; i < n; i++) {
    cin >> first >> second;
    g[first].push_back(second);
    g[second].push_back(first);
  }
  dfs(0, a);
  cout << --mx;
}
