#include <bits/stdc++.h>
using namespace std;
class cmp {
 public:
  bool operator()(const pair<int, int>& lhs, const pair<int, int>& rhs) {
    if (lhs.first == rhs.first) return lhs.second > rhs.second;
    return lhs.first > rhs.first;
  }
};
int bob[2 * 100008];
int alice[2 * 100008];
set<pair<int, int>, cmp> rev_alice;
list<int> adj[2 * 100008];
void DFS(int root, int dist[], int metre, int parent) {
  dist[root] = metre;
  auto it = adj[root].begin();
  while (it != adj[root].end()) {
    if (*it != parent) DFS(*it, dist, metre + 1, root);
    it++;
  }
  return;
}
int main() {
  int n;
  int x;
  int u;
  int v;
  scanf("%d %d", &n, &x);
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    adj[u].push_front(v);
    adj[v].push_front(u);
  }
  DFS(1, alice, 0, 1);
  DFS(x, bob, 0, x);
  for (int i = 1; i <= n; i++) rev_alice.insert(make_pair(alice[i], i));
  auto itr = rev_alice.begin();
  while (itr != rev_alice.end() && itr->first <= bob[itr->second]) {
    itr++;
  }
  printf("%d\n", 2 * (itr->first));
  return 0;
}
