#include <bits/stdc++.h>
using namespace std;
class TaskC {
 public:
  int n, x;
  vector<int> graph[200001];
  int dist1[200001], dist2[200001];
  void dfs(int node, int prev, int* dist) {
    for (auto neighbor : graph[node]) {
      if (neighbor == prev) continue;
      dist[neighbor] = dist[node] + 1;
      dfs(neighbor, node, dist);
    }
  }
  void solve(std::istream& in, std::ostream& out) {
    in >> n >> x;
    for (int i = 1; i < n; ++i) {
      int a, b;
      in >> a >> b;
      graph[a].push_back(b);
      graph[b].push_back(a);
    }
    dist1[1] = 0;
    dfs(1, 1, dist1);
    dist2[x] = 0;
    dfs(x, x, dist2);
    int res = 0;
    for (int i = 1; i <= n; ++i) {
      if (dist2[i] < dist1[i]) {
        res = max(res, dist1[i] * 2);
      }
    }
    out << res;
  }
};
int main() {
  TaskC solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
