#include <bits/stdc++.h>
using namespace std;
const long long hell = 1e9 + 7;
long long inf = 1e18;
const long long N = 2e5 + 9;
bool prime(long long n) {
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long power(long long a, long long b, long long m) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans;
}
long long n, x;
vector<long long> adj[N];
long long dis[N];
long long p[N];
long long depth[N];
void dfs(long long i, long long par) {
  if (par) {
    dis[i] = dis[par] + 1;
  }
  for (auto x : adj[i]) {
    if (x == par) continue;
    dfs(x, i);
  }
}
void dfs1(long long i, long long par) {
  if (par) {
    depth[i] = depth[par] + 1;
  }
  for (auto x : adj[i]) {
    if (x == par) continue;
    dfs1(x, i);
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    cin >> n >> x;
    for (long long i = 0; i < n - 1; i++) {
      long long x, y;
      cin >> x >> y;
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
    dfs(1, 0);
    dfs1(x, 0);
    long long y = 0;
    for (long long i = 1; i <= n; i++) {
      if (dis[i] > depth[i]) y = max(y, dis[i]);
    }
    cout << 2 * y;
  }
  return 0;
}
