#include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 62) - 1;
const long long MOD = 1e9 + 7;
const int MAX = 1e9;
const int N = 2e5 + 10;
using namespace std;
int bPow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1ll) {
      res = 1ll * res * a % MOD;
    }
    b >>= 1;
    a = 1ll * a * a % MOD;
  }
  return res;
}
int gcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<int> mpf(N, 0);
void sieve() {
  for (int i = 2; i < N; ++i) {
    if (!mpf[i])
      for (int j = 2 * i; j < N; j += i) {
        mpf[j] = i;
      }
  }
}
int n, x;
vector<int> adj[N];
vector<int> distAlice(N, 0), distBob(N, 0);
void dfs(int child, int parent, vector<int>& dist) {
  dist[child] = dist[parent] + 1;
  for (auto v : adj[child]) {
    if (v != parent) {
      dfs(v, child, dist);
    }
  }
}
void solve() {
  cin >> n >> x;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v), adj[v].push_back(u);
  }
  distAlice[0] = -1;
  distBob[0] = -1;
  dfs(1, 0, distAlice);
  dfs(x, 0, distBob);
  int ans = 0;
  for (int i = 1; i < n + 1; ++i) {
    if (distBob[i] < distAlice[i]) {
      ans = max(ans, 2 * distAlice[i]);
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
