#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
int dis1[2 * N], dis2[2 * N];
vector<int> ed[2 * N];
vector<int> vk;
int main() {
  memset(dis1, -1, sizeof dis1);
  memset(dis2, -1, sizeof dis2);
  dis1[1] = 0;
  queue<int> q;
  int n, x;
  scanf("%d%d", &n, &x);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    ed[a].push_back(b);
    ed[b].push_back(a);
  }
  q.push(1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < ed[u].size(); i++) {
      int v = ed[u][i];
      if (dis1[v] == -1) {
        dis1[v] = dis1[u] + 1;
        q.push(v);
      }
    }
  }
  q.push(x);
  dis2[x] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < ed[u].size(); i++) {
      int v = ed[u][i];
      if (dis2[v] == -1) {
        dis2[v] = dis2[u] + 1;
        q.push(v);
      }
    }
  }
  int mx = 0, id = 0;
  for (int i = 2; i <= n; i++) {
    if (dis1[i] > dis2[i]) {
      mx = max(mx, dis1[i]);
    }
  }
  cout << mx * 2 << endl;
}
