#include <bits/stdc++.h>
using namespace std;
const int MAX = 200010;
vector<int> edges[MAX];
int dis1[MAX];
int dis2[MAX];
void get_dis(int cur_pos, int n_step, int dis[]) {
  dis[cur_pos] = n_step;
  for (int i = 0; i < edges[cur_pos].size(); ++i) {
    if (dis[edges[cur_pos][i]] == -1) {
      get_dis(edges[cur_pos][i], n_step + 1, dis);
    }
  }
}
int main() {
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < n - 1; ++i) {
    int b, e;
    cin >> b >> e;
    edges[b].push_back(e);
    edges[e].push_back(b);
  }
  for (int i = 1; i <= n; ++i) {
    dis1[i] = dis2[i] = -1;
  }
  get_dis(1, 0, dis1);
  get_dis(x, 0, dis2);
  int res = 0;
  for (int i = 1; i <= n; ++i) {
    if (dis2[i] < dis1[i]) res = max(res, dis1[i]);
  }
  cout << res * 2 << endl;
  return 0;
}
