#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e9 + 7;
const long long mod = 1e9 + 7;
const long long maxn = 2e5 + 7;
vector<int> s[maxn];
int ans = 0, sum = 0;
int d1[maxn], d2[maxn];
int n, x;
void dfs(int xx, int arry[], int yy) {
  for (int i = 0; i < s[xx].size(); i++) {
    int w = s[xx][i];
    if (w == yy) continue;
    arry[w] = arry[xx] + 1;
    dfs(w, arry, xx);
  }
}
int main() {
  cin >> n >> x;
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    s[a].push_back(b);
    s[b].push_back(a);
  }
  dfs(1, d1, 0);
  dfs(x, d2, 0);
  ans = 0;
  for (int i = 1; i <= n; i++)
    if (d1[i] > d2[i]) ans = max(ans, d1[i]);
  cout << ans * 2 << endl;
  return 0;
}
