#include <bits/stdc++.h>
using namespace std;
long long n, x, x1, p[300000][20], maxx, ans, sx, le, a, b, q, wv;
vector<long long> v[300000];
void dfs(long long u, long long m, long long l) {
  p[u][0] = m;
  if (u == x1) {
    le = l;
    x1 = 10000000000000;
  }
  for (int i = 1; i <= 18; i++) p[u][i] = p[p[u][i - 1]][i - 1];
  for (int i = 0; i < v[u].size(); i++) {
    if (v[u][i] != m) dfs(v[u][i], u, l + 1);
  }
}
int pk(long long u, long long k) {
  for (int i = 18; i >= 0; i--) {
    if ((1 << i) <= k) {
      u = p[u][i];
      k -= 1 << i;
    }
  }
  return u;
}
void dfs1(long long u, long long m, long long l) {
  if (v[u].size() == 1) maxx = max(maxx, l);
  for (int i = 0; i < v[u].size(); i++) {
    if (v[u][i] != m) dfs1(v[u][i], u, l + 1);
  }
}
int main() {
  cin >> n >> x;
  x1 = x;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1, 0, 0);
  if (le % 2 == 1)
    q = le / 2;
  else
    q = le / 2 - 1;
  ans = q * 2;
  wv = pk(x, q);
  sx = le - 2 * q;
  dfs1(wv, p[wv][0], 0);
  ans += maxx * 2 + sx * 2;
  cout << ans;
}
