#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int N, T, A;
vector<int> G[100010];
int lmax, maxp;
void Dfs(int p, int pre, int len) {
  if (len > lmax) {
    lmax = len;
    maxp = p;
  }
  for (int i = 0; i <= ((int)(G[p]).size()) - 1; ++i) {
    int v = G[p][i];
    if (v == pre) continue;
    Dfs(v, p, len + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N >> T >> A;
  for (int i = 1; i <= N - 1; ++i) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  lmax = 0;
  maxp = A;
  Dfs(A, -1, 0);
  cout << lmax - 1 << endl;
  return 0;
}
