#include <bits/stdc++.h>
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
constexpr long long MOD{998244353LL};
constexpr long long MAX_SIZE{3000010LL};
template <long long MOD = MOD>
class Mint {
 public:
  long long x;
  Mint() : x{0LL} {}
  Mint(long long x) : x{x % MOD} {}
  Mint operator-() const { return x ? MOD - x : 0; }
  Mint &operator+=(const Mint &a) {
    if ((x += a.x) >= MOD) {
      x -= MOD;
    }
    return *this;
  }
  Mint &operator-=(const Mint &a) { return *this += -a; }
  Mint &operator*=(const Mint &a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  Mint &operator/=(const Mint &a) {
    Mint b{a};
    return *this *= b.power(MOD - 2);
  }
  Mint operator+(const Mint &a) const { return Mint(*this) += a; }
  Mint operator-(const Mint &a) const { return Mint(*this) -= a; }
  Mint operator*(const Mint &a) const { return Mint(*this) *= a; }
  Mint operator/(const Mint &a) const { return Mint(*this) /= a; }
  bool operator<(const Mint &a) const { return x < a.x; }
  bool operator==(const Mint &a) const { return x == a.x; }
  const Mint power(long long N) {
    if (N == 0) {
      return 1;
    } else if (N % 2 == 1) {
      return *this * power(N - 1);
    } else {
      Mint half = power(N / 2);
      return half * half;
    }
  }
};
template <long long MOD>
Mint<MOD> operator+(long long lhs, const Mint<MOD> &rhs) {
  return rhs + lhs;
}
template <long long MOD>
Mint<MOD> operator-(long long lhs, const Mint<MOD> &rhs) {
  return -rhs + lhs;
}
template <long long MOD>
Mint<MOD> operator*(long long lhs, const Mint<MOD> &rhs) {
  return rhs * lhs;
}
template <long long MOD>
Mint<MOD> operator/(long long lhs, const Mint<MOD> &rhs) {
  return Mint<MOD>{lhs} / rhs;
}
template <long long MOD>
istream &operator>>(istream &stream, Mint<MOD> &a) {
  return stream >> a.x;
}
template <long long MOD>
ostream &operator<<(ostream &stream, const Mint<MOD> &a) {
  return stream << a.x;
}
template <long long MOD = MOD, long long MAX_SIZE = MAX_SIZE>
class Combination {
 public:
  vector<Mint<MOD>> inv, fact, factinv;
  Combination() : inv(MAX_SIZE), fact(MAX_SIZE), factinv(MAX_SIZE) {
    inv[1] = 1;
    for (auto i = 2LL; i < MAX_SIZE; i++) {
      inv[i] = (-inv[MOD % i]) * (MOD / i);
    }
    fact[0] = factinv[0] = 1;
    for (auto i = 1LL; i < MAX_SIZE; i++) {
      fact[i] = Mint<MOD>(i) * fact[i - 1];
      factinv[i] = inv[i] * factinv[i - 1];
    }
  }
  Mint<MOD> operator()(int n, int k) {
    if (n >= 0 && k >= 0 && n - k >= 0) {
      return fact[n] * factinv[k] * factinv[n - k];
    }
    return 0;
  }
  Mint<MOD> catalan(int x, int y) {
    return (*this)(x + y, y) - (*this)(x + y, y - 1);
  }
};
using mint = Mint<MOD>;
using combination = Combination<MOD, MAX_SIZE>;
long long gcd(long long x, long long y) { return y ? gcd(y, x % y) : x; }
vector<int> to[100005];
int n;
vector<int> dist;
void dfs(int v, int d = 0, int p = -1) {
  dist[v] = d;
  for (int u : to[v]) {
    if (u == p) continue;
    dfs(u, d + 1, v);
  }
}
vector<int> calcDist(int s) {
  dist = vector<int>(n);
  dfs(s);
  return dist;
}
int main() {
  int n;
  cin >> n;
  int s, t;
  cin >> s >> t;
  --s;
  --t;
  for (int i = 0; i < (int)(n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> distS = calcDist(s);
  vector<int> distT = calcDist(t);
  int mx = 0;
  for (int i = 0; i < (int)(n); ++i) {
    if (distS[i] < distT[i]) {
      mx = max(mx, distT[i]);
    }
  }
  int ans = mx - 1;
  cout << ans << endl;
  return 0;
}
