#include <bits/stdc++.h>
using namespace std;
vector<int> edge[200005];
int dista[200005], dist[200005];
void bfs(int st) {
  queue<int> Q;
  Q.push(st);
  for (int i = 0; i < 200005; i++) dista[i] = 1000000007;
  dista[st] = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (int v : edge[u]) {
      if (dista[v] > dista[u] + 1) {
        dista[v] = dista[u] + 1;
        Q.push(v);
      }
    }
  }
}
int bfs2(int st) {
  queue<int> Q;
  Q.push(st);
  for (int i = 0; i < 200005; i++) dist[i] = 1000000007;
  dist[st] = 0;
  int ans = 0;
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    ans = max(ans, max(dista[u], dist[u]));
    for (int v : edge[u]) {
      if (dist[v] > dist[u] + 1) {
        dist[v] = dist[u] + 1;
        if (dista[v] > dist[v]) Q.push(v);
      }
    }
  }
  return ans * 2;
}
int main() {
  int n, x;
  scanf("%d %d", &n, &x);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  bfs(1);
  int ans = bfs2(x);
  printf("%d\n", ans);
  return 0;
}
