#include <bits/stdc++.h>
using namespace std;
int vis1[200005], vis2[200005], dis1[200005], dis2[200005], n, x, a, b, i, mx;
vector<int> adj[200005];
void dfs1(int a) {
  int i;
  if (vis1[a]) return;
  vis1[a] = 1;
  for (i = 0; i < adj[a].size(); i++) {
    if (!vis1[adj[a][i]]) {
      dis1[adj[a][i]] = dis1[a] + 1;
      dfs1(adj[a][i]);
    }
  }
}
void dfs2(int a) {
  int i;
  if (vis2[a]) return;
  vis2[a] = 1;
  for (i = 0; i < adj[a].size(); i++) {
    if (!vis2[adj[a][i]]) {
      dis2[adj[a][i]] = dis2[a] + 1;
      dfs2(adj[a][i]);
    }
  }
}
int main() {
  scanf("%d %d", &n, &x);
  for (i = 0; i < n - 1; i++) {
    scanf("%d %d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs1(1);
  dfs2(x);
  for (i = 1; i <= n; i++) {
    if (dis1[i] > dis2[i] && dis1[i] > mx) mx = dis1[i];
  }
  printf("%d", mx * 2);
}
