#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[200005], level1(200005, 0), level2(200005, 0);
long long n, x, ans = 0;
void dfs1(long long v, long long par, long long lev) {
  level1[v] = lev;
  for (long long u : adj[v]) {
    if (u != par) dfs1(u, v, lev + 1);
  }
}
void dfs2(long long v, long long par, long long lev) {
  level2[v] = lev;
  for (long long u : adj[v]) {
    if (u != par) dfs2(u, v, lev + 1);
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> x;
  for (long long i = 1; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs1(1, -1, 0);
  dfs2(x, -1, 0);
  for (long long i = 1; i <= n; i++) {
    if (level1[i] > level2[i]) ans = max(ans, 2 * level1[i]);
  }
  cout << ans;
}
