#include <bits/stdc++.h>
using namespace std;
vector<int> vec[200005];
int pre[200005], deep[200005], MAX[200005];
void dfs(int u, int fa) {
  pre[u] = fa;
  deep[u] = deep[fa] + 1;
  MAX[u] = 0;
  for (int i = 0; i < vec[u].size(); i++) {
    int v = vec[u][i];
    if (v == fa) continue;
    dfs(v, u);
    MAX[u] = max(MAX[u], MAX[v] + 1);
  }
}
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  dfs(1, 0);
  x = m;
  for (int i = 0; i < (deep[m] - 2) / 2; i++) {
    x = pre[x];
  }
  cout << 2 * MAX[x] + (deep[m] + 1) / 2 * 2 << endl;
}
