#include <bits/stdc++.h>
using namespace std;
class Solution {
 public:
  std::vector<std::vector<int>> v;
  std::vector<bool> visited;
  std::vector<int> depth;
  void dfs_depth(int cur, int cur_depth) {
    depth[cur] = cur_depth;
    visited[cur] = true;
    for (auto& next : v[cur]) {
      if (!visited[next]) dfs_depth(next, cur_depth + 1);
    }
  }
  int largest_depth(int cur) {
    visited[cur] = true;
    int ans = depth[cur];
    for (auto& next : v[cur]) {
      if (!visited[next] && depth[next] > depth[cur])
        ans = std::max(largest_depth(next), ans);
    }
    return ans;
  }
  void solve(std::istream& in, std::ostream& out) {
    int n, x;
    in >> n >> x;
    --x;
    v.resize(n);
    depth.resize(n);
    visited.resize(n);
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      in >> a >> b;
      --a;
      --b;
      v[a].push_back(b);
      v[b].push_back(a);
    };
    dfs_depth(0, 0);
    int start = x;
    while (start != 0) {
      if (depth[start] == depth[x] / 2 + 1) break;
      for (auto& next : v[start])
        if (depth[next] < depth[start]) {
          start = next;
          break;
        }
    }
    std::fill(visited.begin(), visited.end(), false);
    out << largest_depth(start) * 2 << '\n';
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
