#include <bits/stdc++.h>
using namespace std;
int s[200005], vis[200005];
vector<int> vec[200005];
void bfs(int x) {
  vis[x] = 1;
  s[x] = 0;
  queue<pair<int, int> > q;
  q.push(pair<int, int>(x, 0));
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    for (int i = 0; i < vec[p.first].size(); i++) {
      int a = vec[p.first][i];
      if (!vis[a]) {
        vis[a] = 1;
        s[a] = p.second + 1;
        q.push(pair<int, int>(a, s[a]));
      }
    }
  }
}
int main() {
  int n, x;
  scanf("%d%d", &n, &x);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  bfs(1);
  memset(vis, 0, sizeof(vis));
  int sum = 0, dx = s[x] / 2;
  ;
  vis[x] = 1;
  queue<pair<int, int> > q;
  q.push(pair<int, int>(x, 0));
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    sum = max(sum, 2 * s[p.first]);
    for (int i = 0; i < vec[p.first].size(); i++) {
      int a = vec[p.first][i];
      if (!vis[a] && s[a] > dx) {
        vis[a] = 1;
        q.push(pair<int, int>(a, p.second + 1));
      }
    }
  }
  printf("%d\n", sum);
  return 0;
}
