#include <bits/stdc++.h>
using namespace std;
long long lvla[200005], lvlb[200005];
vector<long long> graph[200005];
long long n, x, u, v;
void dfs(long long p, long long q) {
  for (long long i = 0; i < graph[p].size(); i++) {
    long long node = graph[p][i];
    if (node == q) {
      continue;
    }
    lvla[node] = lvla[p] + 1;
    dfs(node, p);
  }
}
void dfs1(long long p, long long q) {
  for (long long i = 0; i < graph[p].size(); i++) {
    long long node = graph[p][i];
    if (node == q) {
      continue;
    }
    lvlb[node] = lvlb[p] + 1;
    dfs1(node, p);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> x;
  for (long long i = 0; i < n - 1; i++) {
    cin >> u >> v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(1, -1);
  dfs1(x, -1);
  long long mx = INT_MIN;
  for (long long i = 1; i <= n; i++) {
    if (lvla[i] > lvlb[i]) {
      mx = max(lvla[i], mx);
    }
  }
  cout << 2 * mx << endl;
}
