#include <bits/stdc++.h>
using namespace std;
int n, x;
vector<int> adjl[200010];
int par[200010];
int lev[200010];
void find_p(int u, int p) {
  par[u] = p;
  if (p != -1) {
    lev[u] = lev[p] + 1;
  }
  int sz = adjl[u].size();
  for (int i = 0; i <= sz - 1; i++) {
    int v = adjl[u][i];
    if (v == p) {
      continue;
    }
    find_p(v, u);
  }
}
int sptab[200010][20];
void crptab() {
  int root = 1;
  memset((sptab), -1, sizeof(sptab));
  lev[root] = 0;
  find_p(root, -1);
  for (int j = 0; (1 << j) < n; j++) {
    for (int i = 1; i <= n; i++) {
      if (j == 0) {
        sptab[i][j] = par[i];
        continue;
      }
      if (sptab[i][j - 1] != -1) {
        sptab[i][j] = sptab[sptab[i][j - 1]][j - 1];
      }
    }
  }
}
int lca(int nodea, int nodeb) {
  int na, nb;
  if (lev[nodea] >= lev[nodeb]) {
    na = nodea;
    nb = nodeb;
  } else {
    na = nodeb;
    nb = nodea;
  }
  int lgn = 0;
  for (int i = 0; (1 << i) <= lev[na]; i++) {
    lgn = i;
  }
  for (int i = lgn; i >= 0; i--) {
    if ((lev[na] - (1 << i)) >= (lev[nb])) {
      na = sptab[na][i];
    }
  }
  if (na == nb) {
    return na;
  }
  for (int i = lgn; i >= 0; i--) {
    if (par[na] == par[nb]) {
      break;
    }
    if ((sptab[na][i] != -1) && (sptab[na][i] != sptab[nb][i])) {
      na = sptab[na][i];
      nb = sptab[nb][i];
    }
  }
  return par[na];
}
int main() {
  std::ios_base::sync_with_stdio(false);
  ;
  cin >> n >> x;
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adjl[u].push_back(v);
    adjl[v].push_back(u);
  }
  int ans = 0;
  crptab();
  bool chk = 0;
  for (int i = 1; i <= n; i++) {
    int lc = lca(x, i);
    if (lev[lc] > (lev[x] - lev[lc])) {
      ans = max(ans, lev[i] * 2);
    }
  }
  cout << ans << "\n";
  return 0;
}
