#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
int n, x;
vector<int> G[maxn];
int dep[maxn];
int vis[maxn];
int depB;
void add_edge(int a, int b) {
  G[a].push_back(b);
  G[b].push_back(a);
}
void getDepth(int u, int f) {
  vis[u] = 1;
  dep[u] = dep[f] + 1;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (!vis[v]) getDepth(v, u);
  }
}
void dfs(int b, int depA) {
  vis[b] = 1;
  for (int i = 0; i < G[b].size(); i++) {
    int u = G[b][i];
    if (!vis[u]) {
      if (dep[b] > depA && dep[u] <= depA + 1)
        depB = max(depB, dep[b]);
      else
        dfs(u, depA + 1);
    }
  }
  depB = max(depB, dep[b]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> x;
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    cin >> a >> b;
    add_edge(a, b);
  }
  memset(vis, 0, sizeof(vis));
  getDepth(1, 0);
  memset(vis, 0, sizeof(vis));
  dfs(x, 1);
  int res = (depB - dep[1]) * 2;
  cout << res << endl;
  return 0;
}
