#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int power(long long int x, long long int y) {
  if (y == 0) return 1;
  return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2));
}
vector<long long int> primeNumbers;
void SieveOfEratosthenes(int n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (int p = 2; p <= n; p++) {
    if (prime[p]) {
      primeNumbers.push_back(p);
    }
  }
}
vector<vector<int> > v(200005);
int distanceRoot[200005];
int distanceBob[200005];
int visit[200005];
void dfsRoot(int index, int distance) {
  visit[index] = 1;
  distanceRoot[index] = distance;
  for (int i = 0; i < v[index].size(); i++) {
    int node = v[index][i];
    if (visit[node] == 1)
      continue;
    else {
      dfsRoot(node, distance + 1);
    }
  }
}
void dfsBob(int index, int distance) {
  visit[index] = 1;
  distanceBob[index] = distance;
  for (int i = 0; i < v[index].size(); i++) {
    int node = v[index][i];
    if (visit[node] == 1)
      continue;
    else {
      dfsBob(node, distance + 1);
    }
  }
}
void pre() {}
void solve() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfsRoot(1, 0);
  for (int i = 1; i <= n; i++) visit[i] = 0;
  dfsBob(x, 0);
  int ans = 2;
  for (int i = 1; i <= n; i++) {
    if (distanceRoot[i] > distanceBob[i]) {
      ans = max(ans, distanceRoot[i] * 2);
    }
  }
  cout << ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  pre();
  while (t--) {
    solve();
    if (t > 0) {
      cout << endl;
    }
  }
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
  return 0;
}
