#include <bits/stdc++.h>
using namespace std;
long long k, m, t, s, ans, mx, dp[200001], x, n, l, r;
vector<long long> verr[200001];
void Rec(long long v, long long d, long long pre) {
  dp[v] = d;
  for (int i = 0; i < verr[v].size(); i++) {
    long long to = verr[v][i];
    if (to != pre) Rec(to, d + 1, v);
  }
}
void dfs(long long v, long long d, long long pre) {
  mx = max(mx, dp[v] * 2);
  for (int i = 0; i < verr[v].size(); i++) {
    long long to = verr[v][i];
    if (to != pre && dp[to] > d + 1) dfs(to, d + 1, v);
  }
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> x;
  for (int i = 1; i < n; i++) {
    cin >> l >> r;
    verr[l].push_back(r);
    verr[r].push_back(l);
  }
  Rec(1, 0, 0);
  dfs(x, 0, 0);
  cout << mx;
}
