#include <bits/stdc++.h>
using namespace std;
long long n, x;
long long a[1000005];
long long dist[1000][1000];
long long parent[200005];
long long visited[200005] = {0};
vector<long long> v[200005];
void dfs(long long s) {
  visited[s] = 1;
  for (long long j = 0; j < v[s].size(); j++) {
    if (!visited[v[s][j]]) {
      parent[v[s][j]] = s;
      dfs(v[s][j]);
    }
  }
}
long long height(long long s) {
  if (v[s].size() == 1) {
    return 0;
  }
  long long ans3 = 0;
  for (long long j = 0; j < v[s].size(); j++) {
    if (v[s][j] != parent[s]) {
      ans3 = max(ans3, height(v[s][j]));
    }
  }
  return 1 + ans3;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> x;
  for (long long i = 0; i < n - 1; i++) {
    long long c, b;
    cin >> c >> b;
    v[c].push_back(b);
    v[b].push_back(c);
  }
  parent[1] = -1;
  dfs(1);
  long long count = 0;
  long long y = x;
  while (x != 1) {
    x = parent[x];
    count++;
  }
  long long b = (count - 1) / 2;
  long long ans = count - b;
  while (b != 0) {
    b--;
    y = parent[y];
  }
  long long ans2 = height(y);
  cout << 2 * (ans + ans2) << endl;
  return 0;
}
