#include <bits/stdc++.h>
using namespace std;
const long long MOD = pow(10, 9) + 7;
long long fac[1001];
template <typename T, typename U>
static inline void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static inline void amax(T &x, U y) {
  if (x < y) x = y;
}
void SieveOfEratosthenes(long long n) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (long long p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (long long i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long p = 2; p <= n; p++)
    if (prime[p])
      ;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long modInverse(long long n, long long p) { return power(n, p - 2, p); }
long long nCrModPFermat(long long n, long long r, long long p) {
  if (n < r) return 0;
  if (r == 0) return 1;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
void dfs(long long v, vector<vector<long long>> &adj, vector<long long> &used,
         vector<long long> &maxD) {
  for (long long u : adj[v]) {
    if (!used[u]) {
      used[u] = 1;
      if (adj[u].size() == 1 && u != 1) {
        maxD[u] = 0;
        amax(maxD[v], 1 + maxD[u]);
      } else {
        dfs(u, adj, used, maxD);
        amax(maxD[v], 1 + maxD[u]);
      }
    }
  }
}
void solve() {
  long long n, x, i;
  cin >> n >> x;
  vector<vector<long long>> adj(n + 1);
  long long u, v;
  for (i = 2; i <= n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  vector<long long> d(n + 1);
  d[1] = 0;
  vector<long long> visited(n + 1);
  vector<long long> parent(n + 1);
  visited[1] = 1;
  parent[1] = 0;
  queue<long long> q;
  q.push(1);
  while (!q.empty()) {
    long long p = q.front();
    q.pop();
    for (auto el : adj[p]) {
      if (!visited[el]) {
        visited[el] = 1;
        q.push(el);
        d[el] = d[p] + 1;
        parent[el] = p;
      }
    }
  }
  vector<long long> maxD(n + 1), used(n + 1);
  used[1] = 1;
  dfs(1, adj, used, maxD);
  long long f = 1, ans = max(maxD[x] * 2, (abs(d[1] - d[x]) + maxD[x]) * 2),
            start = x;
  while (f) {
    long long el = parent[x];
    if (abs(d[el] - d[1]) > abs(d[el] - d[start])) {
      long long z = max(maxD[el] * 2, (abs(d[1] - d[el]) + maxD[el]) * 2);
      amax(ans, z);
      x = el;
    } else {
      f = 0;
      break;
    }
  }
  cout << ans << endl;
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long test = 1;
  switch (test) {
    case 1:
      solve();
      break;
    case 2: {
      long long t;
      cin >> t;
      while (t--) {
        solve();
      }
    }; break;
  }
}
