#include <bits/stdc++.h>
const int inf = 1e9 + 7;
using namespace std;
int n, x, a, b;
vector<int> adj[333300];
inline void bfs() {
  int mx = 0;
  queue<int> q;
  vector<int> dist(n + 1, inf);
  dist[1] = 0;
  q.push(1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      if (dist[u] + 1 < dist[v]) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
  q.push(x);
  vector<int> dist2(n + 1, inf);
  dist2[x] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      if (dist2[u] + 1 < dist2[v]) {
        dist2[v] = dist2[u] + 1;
        if (dist[v] > dist2[v]) q.push(v);
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    if (dist2[i] != inf) mx = max(mx, dist[i]);
  }
  cout << 2 * mx;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> x;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  bfs();
  return 0;
}
