#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int dist[N];
int d_alice[N];
int d_bob[N];
vector<int> g[N];
void dfs(int u, int last, int d) {
  dist[u] = d;
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i];
    if (v != last) dfs(v, u, d + 1);
  }
}
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, 0, 0);
  memcpy(d_alice, dist, sizeof(dist));
  dfs(x, 0, 0);
  memcpy(d_bob, dist, sizeof(dist));
  int ans = 0;
  for (int i = 2; i <= n; i++) {
    if (d_bob[i] < d_alice[i]) {
      ans = max(ans, 2 * d_alice[i]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
