#include <bits/stdc++.h>
using namespace std;
vector<bool> vis(1000000, false);
vector<vector<int> > g;
void print(vector<pair<int, int> >& v) {
  cout << endl;
  for (int i = 0; i < v.size(); ++i)
    cout << v[i].second + 1 << " " << v[i].first << endl;
}
int main() {
  int v, x, e;
  cin >> v;
  cin >> x;
  --x;
  e = v - 1;
  g.resize(v);
  int a, b;
  for (int i = 0; i < e; i++) {
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q;
  q.push(0);
  vector<pair<int, int> > dist(v);
  int ini = 0;
  dist[0] = {0, 0};
  while (!(q.empty())) {
    int ver = q.front();
    q.pop();
    vis[ver] = true;
    for (int i = 0; i < g[ver].size(); ++i) {
      int j = g[ver][i];
      if (!vis[j]) {
        dist[j] = {dist[ver].first + 1, j};
        q.push(j);
      }
    }
  }
  queue<int> q2;
  q2.push(x);
  vector<pair<int, int> > dist2(v);
  int ini2 = 0;
  dist2[x] = {0, x};
  vector<bool> vis(1000000, false);
  while (!(q2.empty())) {
    int ver = q2.front();
    q2.pop();
    vis[ver] = true;
    for (int i = 0; i < g[ver].size(); ++i) {
      int j = g[ver][i];
      if (!vis[j]) {
        dist2[j] = {dist2[ver].first + 1, j};
        q2.push(j);
      }
    }
  }
  int ans = 0;
  sort(dist2.begin(), dist2.end());
  for (int i = v - 1; i >= 0; --i) {
    if (dist[x].first + dist[dist2[i].second].first == dist2[i].first) continue;
    if (dist[x].first + dist2[i].first == dist[dist2[i].second].first) {
      ans = max(ans, 2 * (dist[dist2[i].second].first));
    } else if (dist2[i].first < dist[dist2[i].second].first) {
      ans = max(ans, 2 * (dist[dist2[i].second].first));
    }
  }
  cout << ans;
  return 0;
}
