#include <bits/stdc++.h>
using namespace std;
int dis[200010], lle[200010];
vector<int> adj[200010];
void dfs(int x, int f, int ar[]) {
  for (int i = 0; i < adj[x].size(); i++) {
    int v = adj[x][i];
    if (v != f) {
      ar[v] = ar[x] + 1;
      dfs(v, x, ar);
    }
  }
}
int main() {
  int n, x, a, b, m = 0;
  cin >> n >> x;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 0, dis);
  dfs(x, 0, lle);
  for (int i = 1; i <= n; i++)
    if (lle[i] < dis[i]) m = max(m, dis[i]);
  cout << m * 2;
}
