#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<int> adj[N];
int p[N];
int dp[N];
int lvl[N];
int n, x;
int dfs(int u = 0, int par = -1, int l = 0) {
  p[u] = par;
  lvl[u] = l;
  dp[u] = l;
  for (int nxt : adj[u]) {
    if (nxt != par) {
      dp[u] = max(dp[u], dfs(nxt, u, l + 1));
    }
  }
  return dp[u];
}
int main() {
  scanf("%d %d", &n, &x);
  x--;
  int a, b, node;
  for (int i = 0; i < int(n - 1); i++) {
    scanf("%d %d", &a, &b);
    a--, b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs();
  int cur = lvl[x];
  a = 0, b = lvl[x], node = x;
  bool flag = true;
  while (a + 1 < b) {
    if (flag) {
      a++;
      flag = false;
    } else {
      b--;
      node = p[node];
      flag = true;
    }
  }
  printf("%d\n", dp[node] * 2);
  return 0;
}
