#include <bits/stdc++.h>
using namespace std;
int f[200010];
int g[200010];
vector<int> v[200010];
int n, m;
vector<int> l;
int dfs(int x, int fa) {
  int ma = 0;
  g[x] = fa;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != fa) {
      int y = dfs(v[x][i], x);
      ma = max(ma, y);
    }
  }
  return f[x] = ma + 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  int t = 0;
  for (int i = m; i != 1; i = g[i]) t++;
  int t2 = (t - 1) / 2;
  int ma = -1;
  for (int i = 1, j = m; i <= t2 + 1; i++, j = g[j]) {
    ma = max(ma, t - i + f[j] - 1);
  }
  cout << (ma + 1) * 2 << endl;
  return 0;
}
