#include <bits/stdc++.h>
using namespace std;
const int N = 200200;
int n, x, d[N], e[N];
vector<int> g[N];
int go(int a, int f, int b) {
  e[a] = b;
  d[a] = f;
  for (int i = 0; i < g[a].size(); ++i) {
    if (g[a][i] != f) e[a] = max(e[a], go(g[a][i], a, b + 1));
  }
  return e[a];
}
int main() {
  cin >> n >> x;
  for (int i = 1, a, b; i < n && cin >> a >> b; ++i)
    g[a].push_back(b), g[b].push_back(a);
  go(1, 0, 0);
  int h = 0;
  for (int i = x; i != 1; ++h, i = d[i])
    ;
  h = (h - 1) / 2;
  while (h-- > 0) x = d[x];
  cout << e[x] * 2 << endl;
}
