#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long N = 2e5 + 10;
long long ans[N];
vector<long long> v[N];
long long vis[N], level[N];
long long n, m;
long long c = 0, mn = 0;
void dfs(long long x) {
  vis[x] = 1;
  for (auto it : v[x]) {
    if (!vis[it]) {
      level[it] = level[x] + 1;
      dfs(it);
    }
  }
}
void dfs1(long long x) {
  vis[x] = 1;
  if (level[x] <= abs(level[m] - level[x])) return;
  for (auto it : v[x]) {
    if (!vis[it]) {
      mn = max(level[it], mn);
      dfs1(it);
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 0; i < n - 1; i++) {
    long long x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1);
  memset(vis, 0, sizeof(vis));
  mn = max(level[m], mn);
  dfs1(m);
  cout << 2 * mn << endl;
}
