#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int xChange[] = {0, 1, 0, -1};
int yChange[] = {1, 0, -1, 0};
const int N = 200005;
vector<int> adj[N];
int n, b, dis[N], nb, disx[N];
void DFS(int node, int par, int cnt, int arr[]) {
  for (int i = 0; i < adj[node].size(); i++) {
    int to = adj[node][i];
    if (to != par) {
      arr[to] = cnt;
      DFS(to, node, cnt + 1, arr);
    }
  }
}
void dfs(int node, int par) {
  for (int i = 0; i < adj[node].size(); i++) {
    int to = adj[node][i];
    if (to == b && !nb) {
      nb = node;
    }
    if (to != par) {
      dfs(to, node);
    }
  }
}
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL);
  cin >> n >> b;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, 0);
  DFS(1, 0, 1, dis);
  DFS(b, 0, 1, disx);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (dis[i] > disx[i]) {
      ans = max(ans, dis[i]);
    }
  }
  cout << ans * 2;
  return 0;
}
