#include <bits/stdc++.h>
using namespace std;
const pair<int, int> queen[8] = {pair<int, int>(-1, 0), pair<int, int>(-1, 1),
                                 pair<int, int>(0, 1),  pair<int, int>(1, 1),
                                 pair<int, int>(1, 0),  pair<int, int>(1, -1),
                                 pair<int, int>(0, -1), pair<int, int>(-1, -1)};
const int maxN = 2e5 + 11;
typedef int i_N[maxN];
int N, x;
vector<int> adj[maxN];
i_N L, P, F;
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return pair<int, int>(a.first + b.first, a.second + b.second);
}
void bfs(const int U, int *L) {
  queue<int> bfs_node;
  bfs_node.push(U);
  memset(P, 0, sizeof(P));
  P[U] = -1;
  while (!bfs_node.empty()) {
    const int u = bfs_node.front();
    bfs_node.pop();
    for (int i = 0; i < (int)adj[u].size(); i++) {
      const int v = adj[u][i];
      if (P[v]) continue;
      P[v] = u;
      L[v] = L[u] + 1;
      bfs_node.push(v);
    }
  }
}
int main() {
  cin >> N >> x;
  for (int i = 1; i <= N - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  bfs(1, L);
  bfs(x, F);
  int ans = 0;
  for (int u = 1; u <= N; u++)
    if (L[u] > F[u]) ans = max(ans, L[u]);
  cout << ans * 2;
}
