#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, x, height, levelBob[N], levelAlice[N], res = 0;
bool visited[N], bob = true, alice = false;
vector<int> adj[N];
void dfs(int src, int par, int dist[]) {
  visited[src] = true;
  dist[src] = dist[par] + 1;
  for (int i = 0; i < adj[src].size(); i++) {
    int u = adj[src][i];
    if (!visited[u]) {
      if (u != par) {
        dfs(u, src, dist);
      }
    }
  }
}
void input() {
  cin >> n >> x;
  x--;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
}
int main(int argc, char const *argv[]) {
  input();
  levelBob[0] = -1;
  levelAlice[0] = -1;
  dfs(0, 0, levelAlice);
  for (int i = 0; i < n; i++) {
    visited[i] = false;
  }
  dfs(x, 0, levelBob);
  for (int i = 0; i < n; i++) {
    if (levelBob[i] < levelAlice[i]) {
      res = max(res, 2 * levelAlice[i]);
    }
  }
  cout << res;
  return 0;
}
