#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x(0), w(1);
  char c = getchar();
  while (c ^ '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') w = -1, c = getchar();
  while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0', c = getchar();
  return x * w;
}
int n, p, x, y, cur, ans, las, dep[200010], fa[200010], h[200010];
int head[200010], nxt[400010], to[400010], cnt;
inline void add(int u, int v) {
  to[++cnt] = v;
  nxt[cnt] = head[u];
  head[u] = cnt;
}
void dfs(int u, int Fa) {
  fa[u] = Fa;
  h[u] = 1;
  for (int i = head[u]; i; i = nxt[i]) {
    if (to[i] == Fa) continue;
    dep[to[i]] = dep[u] + 1;
    dfs(to[i], u);
    h[u] = max(h[u], h[to[i]] + 1);
  }
}
int main() {
  n = read(), p = read();
  for (int i = 1; i < n; ++i) {
    x = read(), y = read();
    add(x, y);
    add(y, x);
  }
  dep[1] = 1;
  dfs(1, -1);
  cur = p;
  ans = (dep[p] - 1) * 2;
  while (cur != -1) {
    if (dep[p] - dep[cur] >= dep[cur] - 1) break;
    for (int i = head[cur]; i; i = nxt[i]) {
      if (to[i] == fa[cur]) continue;
      if (to[i] == las) continue;
      ans = max(ans, 2 * (h[to[i]] + dep[cur] - 1));
    }
    las = cur;
    cur = fa[cur];
  }
  printf("%d", ans);
  return 0;
}
