#include <bits/stdc++.h>
const int maxn = 2e5 + 2;
const long long mod = 1e9 + 7, inf = 1e18;
using namespace std;
int steps[maxn], steps1[maxn];
vector<int> adj[maxn];
bool seen[maxn], seen1[maxn];
void dfs(int u, int s) {
  if (seen[u]) return;
  seen[u] = 1;
  steps[u] = s;
  for (auto v : adj[u]) dfs(v, s + 1);
}
void dfs1(int u, int s) {
  if (seen1[u]) return;
  seen1[u] = 1;
  steps1[u] = s;
  for (auto v : adj[u]) dfs1(v, s + 1);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  dfs(1, 0);
  dfs1(x, 0);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (steps1[i] < steps[i]) ans = max(ans, (steps[i] << 1));
  }
  cout << max(ans, 2) << '\n';
  return 0;
}
