#include <bits/stdc++.h>
using namespace std;
const int oo = (int)1e9;
const int mod = (int)1e9 + 7;
const double PI = acos(-1.0);
const int MAX = 200009;
int n, x;
vector<int> g[MAX];
int p[MAX], L[MAX], depth[MAX];
void DFS(int u, int par) {
  p[u] = par;
  for (int i = 0; i < (int)(g[u]).size(); i++) {
    int v = g[u][i];
    if (v != par) {
      L[v] = 1 + L[u];
      DFS(v, u);
      depth[u] = max(depth[u], 1 + depth[v]);
    }
  }
}
int main() {
  scanf("%d%d", &n, &x);
  --x;
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  DFS(0, -1);
  int init = L[x];
  int ans = 0;
  while (L[x] > init / 2) {
    ans = max(ans, 2 * (L[x] + depth[x]));
    x = p[x];
  }
  cout << ans << endl;
  return 0;
}
