#include <bits/stdc++.h>
using namespace std;
void dfs(vector<vector<int>> &graph, vector<int> &vis, vector<int> &height,
         vector<int> &depth, int s) {
  vis[s] = 1;
  int ans = 0;
  for (int x : graph[s]) {
    if (!vis[x]) {
      depth[x] = depth[s] + 1;
      dfs(graph, vis, height, depth, x);
      ans = max(ans, height[x] + 1);
    }
  }
  height[s] = ans;
  return;
}
int main() {
  int n, x;
  cin >> n >> x;
  x--;
  vector<vector<int>> graph(n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].emplace_back(v);
    graph[v].emplace_back(u);
  }
  vector<int> alheight(n, 0);
  vector<int> bobheight(n, 0);
  vector<int> aldepth(n, 0);
  vector<int> bobdepth(n, 0);
  vector<int> vis(n, 0);
  dfs(graph, vis, alheight, aldepth, 0);
  for (int i = 0; i < n; i++) vis[i] = 0;
  dfs(graph, vis, bobheight, bobdepth, x);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (aldepth[i] > bobdepth[i]) {
      ans = max(ans, aldepth[i] + alheight[i]);
    }
  }
  cout << ans * 2 << endl;
  return 0;
}
