#include <bits/stdc++.h>
using namespace std;
int n, ara[200001], dist[200001], cnt, p, m, a, b, t2, dist2[200001];
bool vis[200001];
vector<int> ad[200001];
void bfs() {
  queue<int> q;
  q.push(1);
  vis[1] = 1, dist[1] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int child : ad[u]) {
      if (!vis[child]) {
        vis[child] = 1;
        q.push(child), dist[child] = dist[u] + 1;
      }
    }
  }
}
void bfs1(int node) {
  queue<int> q;
  q.push(node);
  vis[node] = 1, dist2[node] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int child : ad[u]) {
      if (!vis[child]) {
        vis[child] = 1, dist2[child] = dist2[u] + 1;
        q.push(child);
      }
    }
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    ad[a].push_back(b), ad[b].push_back(a);
  }
  bfs();
  for (int i = 1; i <= n; i++) vis[i] = 0;
  bfs1(m);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (dist[i] > dist2[i]) ans = max(ans, dist[i] * 2);
  }
  cout << ans;
}
