#include <bits/stdc++.h>
const int MAX = 2e5 + 50;
using namespace std;
int dis[MAX], num[MAX];
vector<int> adj[MAX];
void dfs(int x, int f, int temp[]) {
  for (int i = 0; i < adj[x].size(); i++) {
    int v = adj[x][i];
    if (v != f) {
      temp[v] = temp[x] + 1;
      dfs(v, x, temp);
    }
  }
}
int main() {
  int n, x;
  cin >> n >> x;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, 0, dis);
  dfs(x, 0, num);
  int ans = 0;
  for (int i = 1; i <= n; i++)
    if (num[i] < dis[i]) ans = max(ans, dis[i]);
  cout << ans * 2 << endl;
}
