#include <bits/stdc++.h>
using namespace std;
const int inf = 1e6;
int n, x, mark[inf], par[inf], mark2[inf], flat[inf], r, flat2[inf], mx;
vector<int> g[inf];
void dfs(int x) {
  mark[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int p = g[x][i];
    if (!mark[p]) {
      par[p] = x;
      flat[p] = flat[x] + 1;
      dfs(p);
    }
  }
}
void dfs2(int x) {
  mark2[x] = 1;
  for (int i = 0; i < g[x].size(); i++) {
    int p = g[x][i];
    if (!mark2[p]) {
      mx = max(mx, flat[p]);
      dfs2(p);
    }
  }
}
int parent(int r, int a) {
  int y = a;
  for (int i = 0; i < r; i++) {
    y = par[y];
  }
  return y;
}
int main() {
  cin >> n >> x;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  flat[1] = 1;
  par[1] = -1;
  dfs(1);
  r = flat[x] - 1;
  r = parent((r + 1) / 2 - 1, x);
  mark2[par[r]] = 1;
  mark2[r] = 1;
  mx = flat[r];
  dfs2(r);
  cout << (mx - 1) * 2;
  return 0;
}
