#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> l[n];
  int in[n];
  for (int i = 0; i < n; i++) {
    in[i] = 0;
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    l[u - 1].push_back(v - 1);
    l[v - 1].push_back(u - 1);
    in[v - 1]++;
    in[u - 1]++;
  }
  in[0] = 0;
  for (int i = 1; i < n; i++) {
    if (in[i] == 2) {
      in[i] = 0;
    }
  }
  int disa[n];
  int disb[n];
  for (int i = 0; i < n; i++) {
    disa[i] = -1;
    disb[i] = -1;
  }
  disa[0] = 0;
  disb[x - 1] = 0;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (int i = 0; i < l[p].size(); i++) {
      if (disa[l[p][i]] == -1) {
        disa[l[p][i]] = disa[p] + 1;
        q.push(l[p][i]);
      }
    }
  }
  q.push(x - 1);
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (int i = 0; i < l[p].size(); i++) {
      if (disb[l[p][i]] == -1) {
        disb[l[p][i]] = disb[p] + 1;
        q.push(l[p][i]);
      }
    }
  }
  int ans = -1;
  for (int i = 0; i < n; i++) {
    if (in[i] == 1) {
      if (disa[i] > disb[i] && disa[i] > ans) {
        ans = disa[i];
      }
    }
  }
  cout << 2 * ans << endl;
  return 0;
}
