#include <bits/stdc++.h>
using namespace std;
struct bian {
  int to, next;
} e[2000050];
int head[2000005];
int cnt = 0;
int f[2000050];
int mxdp[2000005];
int dep[2000050];
void add(int v, int u) {
  e[cnt].to = v;
  e[cnt].next = head[u];
  head[u] = cnt++;
}
void dfs(int u, int pre, int deep) {
  f[u] = pre;
  dep[u] = mxdp[u] = deep;
  for (int i = head[u]; i != -1; i = e[i].next) {
    int v = e[i].to;
    if (pre == v) continue;
    dfs(v, u, deep + 1);
    mxdp[u] = max(mxdp[u], mxdp[v]);
  }
}
int main() {
  int n, x, a, b;
  scanf("%d%d", &n, &x);
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d", &a, &b);
    add(a, b);
    add(b, a);
  }
  dfs(1, 1, 0);
  int ans = mxdp[x] * 2;
  for (int i = 0, k = x; i < dep[x]; i++, k = f[k]) {
    if (i < dep[k]) {
      ans = max(ans, mxdp[k] * 2);
    } else {
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}
