#include <bits/stdc++.h>
const int N = 2e5 + 5;
using namespace std;
long long int dist1[N];
long long int dist2[N];
vector<vector<long long int> > v(N);
void dfs(int node, int parent, long long int dist[]) {
  dist[node] = dist[parent] + 1;
  for (vector<long long int>::iterator it = v[node].begin();
       it != v[node].end(); it++) {
    if (*it != parent) {
      dfs(*it, node, dist);
    }
  }
}
int main() {
  long long int n;
  long long int x;
  cin >> n >> x;
  for (long long int i = 1; i < n; i++) {
    long long int p, q;
    cin >> p >> q;
    v[p].push_back(q);
    v[q].push_back(p);
  }
  dist1[0] = -1;
  dist2[0] = -1;
  dfs(1, 0, dist1);
  dfs(x, 0, dist2);
  long long int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (dist2[i] < dist1[i]) {
      ans = max(ans, dist1[i] * 2);
    }
  }
  cout << ans;
}
