#include <bits/stdc++.h>
using namespace std;
int n, x;
vector<int> v[200001];
vector<int> ans;
int parent[200001];
int height[200001];
int dfs(int i, int p = 0, int d = 0) {
  parent[i] = p;
  if (i == x) {
    int k = i;
    ans.push_back(i);
    while (parent[k] != 1) {
      ans.push_back(parent[k]);
      k = parent[k];
    }
    ans.push_back(1);
  }
  int m = 0;
  for (auto j : v[i]) {
    if (j == p) continue;
    m = max(m, dfs(j, i, d + 1));
  }
  height[i] = m;
  return 1 + m;
}
int main() {
  cin >> n >> x;
  int t = n - 1;
  while (t--) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  t = dfs(1);
  int y = 0;
  for (int i = 0; i < (ans.size()) / 2; i++) {
    int first = i;
    first += height[ans[i]];
    int second = ans.size() - 1 - i + height[ans[i]];
    int h = second - first;
    y = max(y, first + h + second);
  }
  cout << y;
}
