#include <bits/stdc++.h>
using namespace std;
vector<long long> v[200005];
long long d1[200005], d2[200005];
vector<bool> mark;
void dfs1(long long del, long long dis = 0) {
  mark[del] = 1;
  d1[del] = dis;
  for (long long i = 0; i < v[del].size(); i++) {
    if (!mark[v[del][i]]) dfs1(v[del][i], dis + 1);
  }
}
void dfs2(long long del, long long dis = 0) {
  mark[del] = 1;
  d2[del] = dis;
  for (long long i = 0; i < v[del].size(); i++) {
    if (!mark[v[del][i]]) dfs2(v[del][i], dis + 1);
  }
}
int main(void) {
  long long n, i = 0, k, x, y;
  cin >> n >> k;
  k--;
  for (i = 0; i < n - 1; i++) {
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  mark.resize(n + 1, 0);
  dfs1(0LL);
  mark.clear();
  mark.resize(n + 1, 0);
  dfs2(k);
  long long ans = 0;
  for (i = 0; i < n; i++) {
    if (d1[i] > d2[i]) ans = max(ans, 2 * d1[i]);
  }
  cout << ans;
  return 0;
}
