#include <bits/stdc++.h>
using namespace std;
vector<int> edge[200009], yol(200009), bob(200009);
void dfs1(int node, int anc) {
  for (int i = 0; edge[node].size() > i; i++) {
    if (edge[node][i] == anc) {
      continue;
    }
    yol[edge[node][i]] = yol[node] + 1;
    dfs1(edge[node][i], node);
  }
}
void dfs2(int node, int anc) {
  for (int i = 0; edge[node].size() > i; i++) {
    if (edge[node][i] == anc) {
      continue;
    }
    bob[edge[node][i]] = bob[node] + 1;
    dfs2(edge[node][i], node);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, x;
  cin >> n >> x;
  for (int i = 1; n > i; i++) {
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs1(1, 0);
  dfs2(x, 0);
  int ans = 2;
  for (int i = 1; n >= i; i++) {
    if (yol[i] > bob[i]) {
      ans = max(ans, 2 * yol[i]);
    }
  }
  cout << ans;
}
