#include <bits/stdc++.h>
using namespace std;
using vl = vector<long long>;
using vvl = vector<vl>;
constexpr int MOD = 1000000007;
using long long = long long;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void print(const std::vector<int> &v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}
long long gcd(long long a, long long b) {
  for (;;) {
    if (a == 0) return b;
    b %= a;
    if (b == 0) return a;
    a %= b;
  }
}
long long lcm(long long a, long long b) {
  long long temp = gcd(a, b);
  return temp ? (a / temp * b) : 0;
}
vector<int> E[101010];
int D[101010][2];
void dfs(int cur, int pre, int d, int id) {
  D[cur][id] = d;
  for (auto e : E[cur]) {
    if (e != pre) {
      dfs(e, cur, d + 1, id);
    }
  }
}
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  A--;
  B--;
  for (long long i = 0; i < (long long)N - 1; i++) {
    int x, y;
    cin >> x >> y;
    E[x - 1].push_back(y - 1);
    E[y - 1].push_back(x - 1);
  }
  dfs(A, A, 0, 0);
  dfs(B, B, 0, 1);
  int ma = 0;
  for (long long i = 0; i < (long long)N; i++) {
    if (D[i][0] < D[i][1]) {
      ma = max(ma, D[i][1] - 1);
    }
  }
  return 0;
}
