#include <bits/stdc++.h>
using namespace std;
const int N = int(5e5) + 5;
const int inf = (int)1e9 + 7;
int n, xx;
int h[N], d[N], up[N][20];
vector<int> g[N];
void dfs(int v, int p) {
  up[v][0] = p;
  d[v] = 0;
  h[v] = h[p] + 1;
  for (int i : g[v]) {
    if (i == p) {
      continue;
    }
    dfs(i, v);
    d[v] = max(d[v], d[i] + 1);
  }
}
int main() {
  scanf("%d %d", &n, &xx);
  for (int i = 1; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  h[1] = -1;
  dfs(1, 1);
  int now = 0;
  int ans = 0;
  while (true) {
    if (h[xx] <= now) {
      break;
    }
    ans = max(ans, h[xx] * 2 + d[xx] * 2);
    xx = up[xx][0];
    ++now;
  }
  printf("%d", ans);
  return 0;
}
