#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> g[N];
vector<int> st, pr;
int n, x, mx[N], parent[N], tin[N], tout[N], timer = 0, h[N];
void dfs1(int v) {
  tin[v] = ++timer;
  for (int j = 0; j < (int(g[v].size())); j++) {
    int u = g[v][j];
    if (u != parent[v]) {
      h[u] = h[v] + 1;
      parent[u] = v;
      dfs1(u);
    }
  }
  tout[v] = ++timer;
}
void dfs2(int v) {
  if (((int(g[v].size())) == 1) && (v != 1)) {
    mx[v] = h[v];
  }
  for (int j = 0; j < (int(g[v].size())); j++) {
    int u = g[v][j];
    if (u != parent[v]) {
      dfs2(u);
      if (!((tin[u] <= tin[x]) && (tout[u] >= tout[x]))) {
        mx[v] = max(mx[v], mx[u]);
      }
    }
  }
}
int main() {
  scanf("%d %d", &n, &x);
  for (int i = 1; i <= n - 1; i++) {
    int v, u;
    scanf("%d %d", &v, &u);
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs1(1);
  dfs2(1);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if ((tin[x] <= tin[i]) && (tout[x] >= tout[i])) {
      ans = max(ans, h[i] * 2);
    }
  }
  int c = parent[x], cnt = 1;
  while (c != 1) {
    if (h[c] > cnt) {
      ans = max(ans, mx[c] * 2);
    }
    c = parent[c];
    cnt++;
  }
  printf("%d", ans);
  return 0;
}
