#include <bits/stdc++.h>
using namespace std;
void dfs(long, long, long);
vector<long> s[2 * 100005];
long vis[2 * 100005], cop[2 * 100005];
long m, counta, n, node;
int main() {
  long i, a, b, p;
  std::ios::sync_with_stdio(false);
  cin >> n >> m;
  for (i = 0; i < n - 1; i++) {
    cin >> a >> b;
    s[a].push_back(b);
    s[b].push_back(a);
  }
  counta = -1;
  for (int j = 1; j <= n; j++) vis[j] = 100000000;
  dfs(1, -1, 0);
  for (int j = 1; j <= n; j++) cop[j] = vis[j];
  dfs(m, -1, 0);
  long maxi = -1;
  for (int i = 1; i <= n; i++) {
    if (cop[i] > vis[i])
      if (cop[i] > maxi) maxi = cop[i];
  }
  cout << 2 * maxi;
  return 0;
}
void dfs(long i, long parent, long c) {
  vis[i] = c;
  vector<long>::iterator j;
  for (j = s[i].begin(); j != s[i].end(); ++j) {
    if (*j == parent) continue;
    dfs(*j, i, c + 1);
  }
}
