#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005];
int h[200005], val[200005], parent[200005];
void dfs(int node, int par) {
  h[node] = h[par] + 1;
  parent[node] = par;
  for (int i = 0; i < v[node].size(); i++) {
    if (v[node][i] != par) dfs(v[node][i], node);
  }
  val[node] = h[node];
  for (int i = 0; i < v[node].size(); i++) {
    if (v[node][i] != par) val[node] = max(val[node], val[v[node][i]]);
  }
}
int main() {
  int i, j, k;
  int n;
  scanf("%d", &n);
  scanf("%d", &k);
  for (i = 1; i < n; i++) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  int x = (h[k] - 2) / 2;
  while (x--) {
    k = parent[k];
  }
  printf("%d\n", (val[k] - 1) * 2);
  return 0;
}
