#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int n;
stack<int> q;
void dfs(int i, vector<int> adj[], vector<int> &level) {
  vector<bool> visit(n, false);
  q.push(i);
  visit[i] = true;
  level[i] = 0;
  while (!q.empty()) {
    int x = q.top();
    q.pop();
    for (int y : adj[x]) {
      if (!visit[y]) {
        visit[y] = true;
        q.push(y);
        level[y] = level[x] + 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x;
  cin >> n >> x;
  vector<int> adj[n];
  vector<int> lv1(n), lv2(n);
  for (int i = 0; i < n - 1; i++) {
    int y, z;
    cin >> y >> z;
    adj[y - 1].push_back(z - 1);
    adj[z - 1].push_back(y - 1);
  }
  dfs(0, adj, lv1);
  dfs(x - 1, adj, lv2);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (lv2[i] < lv1[i]) {
      ans = max(ans, lv1[i]);
    }
  }
  cout << 2 * ans;
}
