#include <bits/stdc++.h>
using namespace std;
int n, x, d[200005], dd[200005];
;
vector<int> t[200005];
void dfs1(int p, int s) {
  for (int i = 0; i < t[p].size(); i++) {
    if (d[t[p][i]] > s + 1) {
      d[t[p][i]] = s + 1;
      dfs1(t[p][i], s + 1);
    }
  }
}
int ans = 0;
void dfs2(int p, int s) {
  for (int i = 0; i < t[p].size(); i++) {
    if (dd[t[p][i]] > s + 1 && d[t[p][i]] >= s + 1) {
      dd[t[p][i]] = s + 1;
      ans = max(ans, max(dd[t[p][i]], d[t[p][i]]));
      if (d[t[p][i]] > s + 1) dfs2(t[p][i], s + 1);
    }
  }
}
int main() {
  cin >> n >> x;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    t[a].push_back(b);
    t[b].push_back(a);
    d[i] = 1e9;
    dd[i] = 1e9;
  }
  d[n] = 1e9;
  dd[n] = 1e9;
  d[1] = 0;
  dd[x] = 0;
  dfs1(1, 0);
  ans = max(dd[x], d[x]);
  dfs2(x, 0);
  cout << 2 * ans << endl;
}
