#include <bits/stdc++.h>
using namespace std;
const int MX = 3e5 + 69;
const long long inf = 1e18 + 69;
const long long mod = 1e9 + 7;
const long double eps = 1e-7;
vector<int> v[MX];
int par[27][MX];
int depth[MX];
void dfs(int x, int p) {
  for (auto g : v[x]) {
    if (g == p) {
      continue;
    }
    depth[g] = depth[x] + 1;
    dfs(g, x);
    par[0][g] = x;
  }
}
int lca(int x, int y) {
  if (depth[x] > depth[y]) swap(x, y);
  int i = 22;
  while (depth[x] < depth[y]) {
    if (depth[par[i][y]] >= depth[x]) {
      y = par[i][y];
    }
    i--;
  }
  for (int i = 22; i >= 0; i--) {
    if (par[i][x] != par[i][y]) {
      x = par[i][x];
      y = par[i][y];
    }
  }
  if (x != y) {
    x = par[0][x];
    y = par[0][y];
  }
  return x;
}
int dis(int a, int b) { return (depth[a] + depth[b] - 2 * depth[lca(a, b)]); }
int main() {
  depth[0] = -1;
  int n, x;
  cin >> n >> x;
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, -1);
  for (int i = 1; i < 23; i++) {
    for (int j = 1; j <= n; j++) {
      par[i][j] = par[i - 1][par[i - 1][j]];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (dis(i, x) < depth[i]) {
      ans = max(ans, depth[i]);
    }
  }
  cout << 2 * ans;
  return 0;
}
