#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};
long long n, x, depth[N], p[N], maxDepth[N];
vector<long long> adj[N];
void add_edge(long long u, long long v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
void dfs(long long v, long long u = -1) {
  if (v > 1) depth[v] = depth[u] + 1;
  p[v] = u;
  maxDepth[v] = depth[v];
  for (auto to : adj[v]) {
    if (to != u) {
      dfs(to, v);
      maxDepth[v] = max(maxDepth[v], maxDepth[to]);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> n >> x;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    add_edge(u, v);
  }
  dfs(1);
  long long v = x, ans = 0;
  while (v != 1) {
    if (depth[x] - depth[v] >= depth[v]) break;
    ans = max(ans, maxDepth[v] * 2);
    v = p[v];
  }
  cout << ans;
  return 0;
}
