#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  for (register int i = (0); i < (vec.size()); i++)
    i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}
vector<vector<int>> nodes(100000, vector<int>());
bool findRoute(int from, int node, vector<int> &route, int target) {
  if (node == target) {
    route.push_back(node);
    return true;
  }
  for (register int i = (0); i < (nodes[node].size()); i++) {
    if (nodes[node][i] != from) {
      if (findRoute(node, nodes[node][i], route, target)) {
        route.push_back(node);
        return true;
      }
    }
  }
  return false;
}
int maxDistance(int from, int node) {
  vector<int> dist;
  for (register int i = (0); i < (nodes[node].size()); i++) {
    if (nodes[node][i] != from) {
      dist.push_back(maxDistance(node, nodes[node][i]));
    }
  }
  if (dist.size() == 0) {
    return 0;
  }
  int maxDist = 0;
  for (register int i = (0); i < (dist.size()); i++) {
    maxDist = max(maxDist, dist[i]);
  }
  return maxDist + 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  vector<int> A(N - 1), B(N - 1);
  for (register int i = (0); i < (N - 1); i++) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
    nodes[A[i]].push_back(B[i]);
    nodes[B[i]].push_back(A[i]);
  }
  vector<int> utov;
  findRoute(-1, v, utov, u);
  int distance = utov.size() - 1;
  if (distance == 1) {
    cout << (maxDistance(v, u)) << '\n';
    ;
  } else if (distance == 2) {
    cout << (maxDistance(utov[1], u)) << '\n';
  } else {
    cout << (maxDistance(utov[2], utov[2]) + 1) << '\n';
  }
}
