#include <bits/stdc++.h>
using namespace std;
vector<int> v[200005];
int t1[200005], t2[200005];
bool vis[200005];
int n, x, a, b;
void dfs1(int step, int t) {
  t1[step] = t;
  vis[step] = true;
  for (int i = 0; i < v[step].size(); i++) {
    if (!vis[v[step][i]]) dfs1(v[step][i], t + 1);
  }
}
void dfs2(int step, int t) {
  t2[step] = t;
  vis[step] = true;
  for (int i = 0; i < v[step].size(); i++) {
    if (!vis[v[step][i]]) dfs2(v[step][i], t + 1);
  }
}
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n - 1; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  memset(vis, false, sizeof(vis));
  dfs1(1, 0);
  memset(vis, false, sizeof(vis));
  dfs2(x, 0);
  int maxl = 0;
  for (int i = 1; i <= n; i++) {
    if (t1[i] > t2[i]) maxl = max(maxl, 2 * t1[i]);
  }
  cout << maxl;
  return 0;
}
