#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> g;
vector<int> used;
int distances[200000];
int deepest[200000];
int p[200000];
void dfs(int v) {
  used[v] = 1;
  deepest[v] = distances[v];
  for (int to : g[v]) {
    if (!used[to]) {
      distances[to] = distances[v] + 1;
      p[to] = v;
      dfs(to);
      deepest[v] = max(deepest[v], deepest[to]);
    }
  }
}
int main() {
  int n, x;
  cin >> n >> x;
  --x;
  g.resize(n);
  used.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0);
  int cur = x;
  for (int i = 0; i < (distances[x] - 1) / 2; i++) {
    cur = p[cur];
  }
  cout << deepest[cur] * 2 << endl;
  return 0;
}
