#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, koldfs = 0, kolelment;
  cin >> n >> x;
  kolelment = n;
  int a[n + 1], b[n + 1], chek[n + 1];
  for (int i = 0; i <= n; i++) {
    a[i] = -1;
    b[i] = -1;
    chek[i] = 0;
  }
  vector<int> v[n + 1], ans;
  queue<int> q;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  q.push(1);
  chek[1] = 1;
  while (kolelment > 0) {
    int s;
    for (int i = 0; i < q.size(); i++) {
      a[q.front()] = koldfs;
      kolelment--;
      int f = q.front();
      q.pop();
      q.push(f);
    }
    koldfs++;
    s = q.size();
    while (s > 0) {
      s--;
      for (int i = 0; i < v[q.front()].size(); i++)
        if (chek[v[q.front()][i]] == 0) {
          q.push(v[q.front()][i]);
          chek[v[q.front()][i]] = 1;
        }
      q.pop();
    }
  }
  for (int i = 0; i < q.size(); i++) q.pop();
  kolelment = n;
  koldfs = 0;
  for (int i = 0; i <= n; i++) chek[i] = 0;
  q.push(x);
  chek[x] = 1;
  while (kolelment > 0) {
    int s;
    for (int i = 0; i < q.size(); i++) {
      b[q.front()] = koldfs;
      kolelment--;
      int f = q.front();
      q.pop();
      q.push(f);
    }
    koldfs++;
    s = q.size();
    while (s > 0) {
      s--;
      for (int i = 0; i < v[q.front()].size(); i++)
        if (chek[v[q.front()][i]] == 0) {
          q.push(v[q.front()][i]);
          chek[v[q.front()][i]] = 1;
        }
      q.pop();
    }
  }
  for (int i = 1; i <= n; i++)
    if (a[i] > b[i]) ans.push_back(max(a[i], b[i]) * 2);
  sort(ans.begin(), ans.end());
  cout << ans[ans.size() - 1];
  return 0;
}
