#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int N = 222222;
vector<int> g[N];
int h[N];
bool used[N];
void calc_h(int v, int p, int ch) {
  h[v] = ch;
  for (int i : g[v]) {
    if (i == p) {
      continue;
    }
    calc_h(i, v, ch + 1);
  }
}
void dfs(int v, int d) {
  used[v] = true;
  for (int i : g[v]) {
    if (!used[i] && h[i] > d + 1) {
      dfs(i, d + 1);
    }
  }
}
void solve(istream& cin, ostream& cout) {
  int n, s;
  cin >> n >> s;
  --s;
  for (int i = (1); i < int(n); ++i) {
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  calc_h(0, -1, 0);
  dfs(s, 0);
  int ans = 0;
  for (int i = (0); i < int(n); ++i) {
    if (used[i]) {
      ans = max(ans, h[i]);
    }
  }
  cout << ans * 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve(cin, cout);
  return 0;
}
