#include <bits/stdc++.h>
using namespace std;
const int N = 123456;
const int M = 1234567;
const int P = 400004;
const int A = 256;
long long ncr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  if (n == r) return 1;
  return ncr(n - 1, r - 1) + ncr(n - 1, r);
}
vector<int> v[200005];
int dist1[200005], dist2[200005];
void dfs(int node, int parent, int* dist) {
  for (auto x : v[node]) {
    if (x != parent) {
      dist[x] = dist[node] + 1;
      dfs(x, node, dist);
    }
  }
}
int main(int argc, char const* argv[]) {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, x;
  cin >> n >> x;
  for (int i = 0; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dist1[1] = dist2[x] = 0;
  dfs(1, 0, dist1);
  dfs(x, 0, dist2);
  int ans = 0;
  for (int i = 2; i <= n; ++i) {
    if (dist1[i] > dist2[i]) {
      ans = max(ans, dist1[i] << 1);
    }
  }
  cout << ans << endl;
  return 0;
}
