#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  for (auto v : V) os << v << " ";
  return cout << "";
}
template <class T>
ostream& operator<<(ostream& os, set<T> S) {
  for (auto s : S) os << s << " ";
  return cout << "";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << P.first << " " << P.second;
}
vector<long long> vis;
vector<vector<long long>> adj;
int main() {
  long long i, j, n, f1, f2, t, k, a, b, x1, x2, m, w, z;
  t = 1;
  while (t--) {
    cin >> n >> z;
    vector<pair<long long, long long>> v(n + 1);
    vis.assign(n + 1, 0);
    adj.assign(n + 1, {});
    for (i = 1; i <= n - 1; i++) {
      cin >> a >> b;
      adj[a].push_back(b);
      adj[b].push_back(a);
    }
    long long s;
    queue<long long> q;
    vector<long long> used(n + 1);
    vector<long long> x(n + 1), y(n + 1);
    vector<long long> p(n + 1);
    s = z;
    q.push(s);
    used[s] = 1;
    p[s] = -1;
    while (!q.empty()) {
      long long v = q.front();
      q.pop();
      for (long long u : adj[v]) {
        if (!used[u]) {
          used[u] = 1;
          q.push(u);
          x[u] = x[v] + 1;
          p[u] = v;
        }
      }
    }
    used.assign(n + 1, 0);
    s = 1;
    q.push(s);
    used[s] = 1;
    p[s] = -1;
    while (!q.empty()) {
      long long v = q.front();
      q.pop();
      for (long long u : adj[v]) {
        if (!used[u]) {
          used[u] = 1;
          q.push(u);
          y[u] = y[v] + 1;
          p[u] = v;
        }
      }
    }
    long long ans = 0;
    for (i = 1; i <= n; i++) {
      if (y[i] > x[i]) {
        ans = max(ans, 2 * y[i]);
      }
    }
    cout << ans;
  }
}
