#include <bits/stdc++.h>
using namespace std;
const int M = 200001;
vector<int> g[M];
vector<bool> vis(M);
void solve() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> d(n + 1, M), dx(n + 1, M);
  queue<int> q;
  q.push(1);
  d[1] = 0;
  dx[x] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (auto v : g[u]) {
      if (d[u] + 1 < d[v]) {
        q.push(v);
        d[v] = d[u] + 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) vis[i] = false;
  q.push(x);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (vis[u]) continue;
    vis[u] = true;
    for (auto v : g[u]) {
      if (dx[u] + 1 < dx[v]) {
        q.push(v);
        dx[v] = dx[u] + 1;
      }
    }
  }
  vector<int> leave;
  for (int i = 1; i <= n; i++) {
    if ((int)g[i].size() == 1) leave.push_back(i);
  }
  int ans = 0;
  for (int i = 0; i < (int)leave.size(); i++) {
    int u = leave[i];
    if (d[u] > dx[u] && vis[u]) ans = max(ans, 2 * d[u]);
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int z;
  z = 1;
  for (int z1 = 1; z1 <= z; z1++) {
    solve();
  }
  return 0;
}
