#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
const int N = 1e6 + 10;
const long long mod = 1e9 + 7;
const int base = 131;
const double pi = acos(-1);
const double eps = 1e-8;
inline long long ksm(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod, b >>= 1;
  }
  return ans;
}
long long vis[N], num[N];
long long n, m, k, x, y, z;
long long a[N], b[N], c[N];
long long cx, cy, cnt, ans, sum, flag, t, ff, q;
unordered_map<int, int> mp;
set<string> st;
vector<long long> res, v[N];
struct node {
  int l, r;
} no[N];
void dfs(int x, int fa, int dep) {
  num[x] = dep;
  for (auto to : v[x]) {
    if (to == fa) continue;
    dfs(to, x, dep + 1);
  }
}
void ddfs(int x, int fa, int dep) {
  vis[x] = dep;
  for (auto to : v[x]) {
    if (to == fa) continue;
    ddfs(to, x, dep + 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, -1, 0);
  ddfs(k, -1, 0);
  for (int i = 1; i <= n; i++) {
    if (num[i] > vis[i]) {
      ans = max(ans, num[i] * 2);
    }
  }
  if (x == 1) ans = 0;
  cout << ans << endl;
}
