#include <bits/stdc++.h>
using namespace std;
vector<int> xd[200005];
int dist[200005];
int dist2[200005];
int vis[200005];
int vis2[200005];
void dfs(int i) {
  vis[i] = 1;
  int l = xd[i].size();
  for (int j = 0; j < l; j++) {
    if (vis[xd[i][j]] == 0) {
      dist[xd[i][j]] = dist[i] + 1;
      dfs(xd[i][j]);
    }
  }
}
void dfs2(int x) {
  vis2[x] = 1;
  int l = xd[x].size();
  for (int j = 0; j < l; j++) {
    if (vis2[xd[x][j]] == 0) {
      dist2[xd[x][j]] = dist2[x] + 1;
      dfs2(xd[x][j]);
    }
  }
}
int main() {
  int n;
  int x;
  int a, b;
  cin >> n >> x;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    xd[a].push_back(b);
    xd[b].push_back(a);
  }
  dfs(1);
  dfs2(x);
  int maxi = 0;
  for (int i = 1; i <= n; i++) {
    if (dist2[i] < dist[i]) maxi = max(maxi, dist[i]);
  }
  cout << 2 * maxi << endl;
}
