#include <bits/stdc++.h>
using namespace std;
vector<long long int> a[1000000];
vector<long long int> visitedA(1000000, 0);
vector<long long int> visitedB(1000000, 0);
long long int alice[1000000];
long long int bob[1000000];
void DfsA(long long int root, long long int score) {
  alice[root] = score;
  visitedA[root] = 1;
  for (long long int i = 0; i < a[root].size(); i++) {
    if (!visitedA[a[root][i]]) DfsA(a[root][i], score + 1);
  }
}
void DfsB(long long int root, long long int score) {
  bob[root] = score;
  visitedB[root] = 1;
  for (long long int i = 0; i < a[root].size(); i++) {
    if (!visitedB[a[root][i]]) DfsB(a[root][i], score + 1);
  }
}
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int t = n - 1;
  while (t--) {
    long long int x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  DfsA(1, 0);
  DfsB(k, 0);
  long long int max1 = -1;
  for (long long int i = 1; i <= n; i++) {
    if (alice[i] > bob[i]) {
      max1 = max(max1, 2 * alice[i]);
    }
  }
  cout << max1;
}
