#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template <class T>
using P = pair<T, T>;
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;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
void bfs(int x, VV& tree, vector<bool>& visited, V& dist) {
  queue<int> que;
  que.push(x);
  visited[x] = true;
  dist[x] = 0;
  while (!que.empty()) {
    int X = que.front();
    que.pop();
    visited[X] = true;
    for (auto c : tree[X]) {
      if (!visited[c]) {
        que.push(c);
        visited[c] = true;
        dist[c] = dist[X] + 1;
      }
    }
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  VV G(n);
  for (int i = 0; i < (n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  V dist(n, upper);
  vector<bool> visited(n, false);
  bfs(v, G, visited, dist);
  ll ans = 0;
  ans += *max_element((dist).begin(), (dist).end()) - dist[u];
  ll d = dist[u] - dist[v];
  bool near = true;
  bool t = false;
  while (d > 0) {
    if (!t) {
      if (near)
        d--;
      else
        d++;
      near ^= true;
      t ^= true;
    } else {
      d--;
      t ^= true;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
