#include <bits/stdc++.h>
using namespace std;
map<long long, long long> m;
void dfs(long long x, vector<long long> v[], bool vis[], long long maxd[],
         long long lev[], long long par[]) {
  if (vis[x] == false) vis[x] = true;
  if (v[x].size() == 0) maxd[x] = 0;
  for (long long i = 0; i < v[x].size(); i++) {
    if (vis[v[x][i]] == false) {
      vis[v[x][i]] = true;
      lev[v[x][i]] = lev[x] + 1;
      par[v[x][i]] = x;
      dfs(v[x][i], v, vis, maxd, lev, par);
      maxd[x] = max(maxd[x], maxd[v[x][i]] + 1);
    }
  }
}
signed main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> v[n + 1];
  long long a, b;
  for (long long i = 0; i < n - 1; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  bool vis[n + 1];
  memset(vis, 0, sizeof(vis));
  long long maxd[n + 1];
  memset(maxd, 0, sizeof(maxd));
  long long lev[n + 1];
  long long par[n + 1];
  lev[1] = 0;
  dfs(1, v, vis, maxd, lev, par);
  long long val = x;
  long long ma = 0;
  while (true) {
    long long le = lev[val];
    long long dif = lev[x] - le;
    if (le <= dif) {
      break;
    } else {
      ma = max(ma, 2 * (lev[val] + maxd[val]));
    }
    val = par[val];
  }
  cout << ma << endl;
}
