#include <bits/stdc++.h>
using namespace std;
const long long hell = 1000000007;
const long long mod = 1000000007;
vector<long long> v[200007];
long long vis[200007];
long long d1[200007], dx[200007];
void dfs1(long long node, long long d) {
  vis[node] = 1;
  d1[node] = d;
  for (long long child : v[node]) {
    if (!vis[child]) dfs1(child, d + 1);
  }
}
void dfs2(long long node, long long d) {
  vis[node] = 1;
  dx[node] = d;
  for (long long child : v[node]) {
    if (!vis[child]) dfs2(child, d + 1);
  }
}
void solve() {
  long long n, x;
  cin >> n >> x;
  long long tmp = n - 1;
  while (tmp--) {
    long long a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs1(1, 0);
  memset(vis, 0, sizeof(vis));
  dfs2(x, 0);
  long long ans = 1;
  for (long long i = 1; i <= n; i++) {
    if (d1[i] <= dx[i]) continue;
    ans = max(ans, d1[i]);
  }
  ans *= 2;
  cout << ans;
  return;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  for (long long T = 1; T <= t; T++) {
    solve();
    cout << '\n';
  }
  return 0;
}
