#include <bits/stdc++.h>
using namespace std;
vector<int> v[200001];
bool visit[200001];
bool bit[200001];
vector<int> path;
int longest[200001];
void dfs(int x, int y) {
  visit[x] = true;
  if (x == y) {
    bit[x] = true;
  }
  for (int i = 0; i < v[x].size(); i++) {
    if (!visit[v[x][i]]) {
      dfs(v[x][i], y);
      if (bit[v[x][i]]) {
        path.push_back(v[x][i]);
        bit[x] = true;
      }
      longest[x] = max(longest[x], longest[v[x][i]] + 1);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, last;
  cin >> n >> last;
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, last);
  path.push_back(1);
  int ans = 0;
  int size = path.size();
  for (int i = 0; i < path.size() / 2; i++) {
    ans =
        max(longest[path[i]] + (size - i - 1), max(ans, longest[path[i]] + i));
  }
  cout << 2 * ans;
}
