#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, x;
  cin >> n >> x;
  vector<int> v[n + 1];
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  bool vstd[n + 1];
  int dst1[n + 1];
  int dst2[n + 1];
  memset(vstd, false, sizeof vstd);
  memset(dst1, 0x7f, sizeof dst1);
  memset(dst2, 0x7f, sizeof dst2);
  queue<int> q;
  q.push(1);
  dst1[1] = 0;
  while (q.size()) {
    int node = q.front();
    q.pop();
    if (vstd[node]) continue;
    vstd[node] = true;
    for (auto u : v[node]) {
      dst1[u] = min(dst1[u], dst1[node] + 1);
      q.push(u);
    }
  }
  q.push(x);
  dst2[x] = 0;
  memset(vstd, false, sizeof vstd);
  while (q.size()) {
    int node = q.front();
    q.pop();
    if (vstd[node]) continue;
    vstd[node] = true;
    for (auto u : v[node]) {
      dst2[u] = min(dst2[u], dst2[node] + 1);
      q.push(u);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (dst1[i] > dst2[i]) {
      ans = max(ans, max(2 * dst1[i], 2 * dst2[i]));
    }
  }
  cout << ans << endl;
  return 0;
}
