#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long modl = 998244353;
const double pie = 3.1415926535;
unsigned long long power(unsigned long long x, unsigned long long y) {
  if (y == 0)
    return 1;
  else {
    if (y % 2 == 0)
      return power(x * x, y / 2);
    else
      return x * power(x * x, (y - 1) / 2);
  }
}
long long mod_power(long long x, long long y, long long m) {
  long long r = 1;
  x = x % m;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) r = (r * x) % m;
    y = y / 2;
    x = (x * x) % m;
  }
  return r;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int dp[200010];
bool visited[200010];
int parent[200010];
int siz[200010];
vector<vector<int> > adj;
int dfs(int x, int p, int c) {
  visited[x] = true;
  parent[x] = p;
  siz[x] = c;
  if (adj[x].size() == 1 && x != 1) {
    dp[x] = siz[x];
    return dp[x];
  } else
    dp[x] = 0;
  for (int i : adj[x]) {
    if (!visited[i]) {
      dfs(i, x, c + 1);
      dp[x] = max(dp[x], dp[i]);
    }
  }
  return dp[x];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int TESTS = 1;
  while (TESTS--) {
    int n, x;
    cin >> n >> x;
    adj = vector<vector<int> >(n + 1);
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    memset(visited, false, sizeof(visited));
    dfs(1, -1, 0);
    int steps = siz[x] / 2 - (siz[x] % 2 ? 0 : 1);
    if (steps == -1) {
      cout << 0 << '\n';
      return 0;
    }
    int mx = dp[x];
    int k = 0;
    while (k <= steps) {
      mx = max(mx, dp[x]);
      k++;
      x = parent[x];
    }
    cout << 2 * mx << '\n';
  }
}
