#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
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;
}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
void solve();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(numeric_limits<double>::max_digits10);
  solve();
  return 0;
}
void solve() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vector<vector<int>> t(n, vector<int>());
  int a, b;
  for (int i = (0); i < ((n - 1)); i++) {
    cin >> a >> b;
    a--;
    b--;
    t[a].emplace_back(b);
    t[b].emplace_back(a);
  }
  vector<int> dist(n, 0);
  function<void(int, int, int)> dfs = [&](int c, int p, int d) {
    dist[c] = d;
    if (p != -1 && (int)t[c].size() == 1) return;
    for (int x : t[c]) {
      if (x == p) continue;
      dfs(x, c, d + 1);
    }
  };
  dfs(v, -1, 0);
  int ans = 0;
  function<void(int, int, int)> dfst = [&](int c, int p, int d) {
    if ((int)t[c].size() == 1 || dist[c] == d) {
      chmax(ans, dist[c] - (abs(dist[c] - d) % 2 == 1 ? 1 : 0));
      if (p != -1) return;
    }
    for (int x : t[c]) {
      if (x == p) continue;
      if (dist[x] < d + 1) {
        continue;
      }
      dfst(x, c, d + 1);
    }
  };
  dfst(u, -1, 0);
  cout << ans << EOL;
}
