#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200010;
vector<int> adj[N];
int dist[N];
void prep(int u, int d = 0, int p = -1) {
  dist[u] = d;
  for (int v : adj[u])
    if (v != p) {
      prep(v, d + 1, u);
    }
}
int dfs(int u, int d = 0, int p = -1) {
  if (dist[u] <= d) return 2 * d;
  int ans = 2 * dist[u];
  for (int v : adj[u])
    if (v != p) {
      ans = max(ans, dfs(v, d + 1, u));
    }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  prep(1);
  cout << dfs(x) << endl;
  return 0;
}
