#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int L[maxn], LCA[maxn][20];
queue<int> Q;
vector<int> G[maxn];
void bfs(int nodo) {
  Q.push(nodo);
  L[nodo] = 1;
  while (!Q.empty()) {
    nodo = Q.front();
    Q.pop();
    for (auto i : G[nodo]) {
      if (L[i]) continue;
      L[i] = L[nodo] + 1;
      LCA[i][0] = nodo;
      Q.push(i);
      int lg = log2(L[i]);
      for (int j = 1; j <= lg; j++) LCA[i][j] = LCA[LCA[i][j - 1]][j - 1];
    }
  }
}
int QLCA(int a, int b) {
  if (L[a] < L[b]) swap(a, b);
  int lg = log2(L[a]);
  for (int i = lg; i >= 0; i--)
    if (L[a] - (1 << i) >= L[b]) a = LCA[a][i];
  if (a == b) return a;
  lg = log2(L[a]);
  for (int i = lg; i >= 0; i--)
    if (LCA[a][i] != LCA[b][i] && LCA[a][i]) a = LCA[a][i], b = LCA[b][i];
  return LCA[a][0];
}
int dist(int a, int b) {
  int lca = QLCA(a, b);
  return L[a] + L[b] - 2 * L[lca];
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int N, B, a, b;
  cin >> N >> B;
  for (int i = 1; i < N; i++) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  bfs(1);
  int sol = dist(1, B) * 2;
  for (int i = 1; i <= N; i++) {
    int lca = QLCA(B, i);
    int d1l = dist(1, lca), dbl = dist(B, lca);
    if (d1l <= dbl) continue;
    sol = max(sol, dist(1, i) * 2);
  }
  cout << sol;
  return 0;
}
