#include <bits/stdc++.h>
using namespace std;
int h[200005], n, x, a, b;
vector<int> v[200005];
vector<int> vec;
int dfs(int cur, int par) {
  int ans = 0;
  for (auto i : v[cur]) {
    if (i != par) ans = max(ans, dfs(i, cur));
  }
  h[cur] = ans + 1;
  return h[cur];
}
bool dfs1(int cur, int par) {
  if (cur == x) {
    vec.push_back(x);
    return true;
  }
  for (auto i : v[cur]) {
    if (i != par) {
      if (dfs1(i, cur)) {
        vec.push_back(cur);
        return true;
      }
    }
  }
  return false;
}
int main() {
  scanf("%d %d", &n, &x);
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, 0);
  dfs1(1, 0);
  int n1 = vec.size();
  n1 /= 2;
  int ans = 0;
  for (int i = 0; i < n1; i++) {
    int l1 = h[vec[i]] - 1 + i;
    int l2 = (int)vec.size() - i - 1 + h[vec[i]] - 1;
    ans = max(ans, 2 * max(l1, l2));
  }
  printf("%d", ans);
  return 0;
}
