#include <bits/stdc++.h>
using namespace std;
const int SS = 5e2 + 123;
const int N = 1e5 + 123;
const int NN = 1e6 + 123;
const int M = 1e7 + 123;
const int MM = 1e8 + 123;
const int inf = 1e9 + 123;
const long long INF = 1e18 + 123;
const long long MAXN = 1e10 + 123;
const long long MOD = 1e9 + 7;
const long long mod = 555557;
const double pi = acos(-1.0);
vector<int> g[NN];
int n, m, Clarion, dist, d[NN], ans;
void pepsi(int v, int pr = -1, int lvl = 0) {
  d[v] = lvl;
  for (int to : g[v])
    if (to != pr) pepsi(to, v, lvl + 1);
}
void cola(int v, int pr = -1) {
  ans = max(ans, d[v]);
  for (int to : g[v])
    if (pr != to && d[to] > dist) cola(to, v);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> Clarion;
  for (int i = 1, a, b; i < n; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  pepsi(1);
  dist = d[Clarion] / 2;
  cola(Clarion);
  cout << ans * 2;
}
