#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 10e17 + 9;
const long double p = acos(-1);
int n, x;
vector<int> v[200009];
int dis1[200009];
int dis2[200009];
void dfs1(int node, int p, int k) {
  dis1[node] = k;
  for (int i = 0; i < v[node].size(); i++) {
    int u = v[node][i];
    if (u != p) dfs1(u, node, k + 1);
  }
}
void dfs2(int node, int p, int k) {
  dis2[node] = k;
  for (int i = 0; i < v[node].size(); i++) {
    int u = v[node][i];
    if (u != p) dfs2(u, node, k + 1);
  }
}
int main() {
  cin >> n >> x;
  x--;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b, a--, b--;
    v[a].push_back(b), v[b].push_back(a);
  }
  dfs1(0, 0, 0);
  dfs2(x, x, 0);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    int x = 0;
    if (dis2[i] < dis1[i]) x = dis1[i];
    mx = max(mx, x);
  }
  cout << mx * 2 << endl;
}
