#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e10;
const long double EPS = 1e-10;
const long double PI = 3.141592653589793;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
const pair<long long, long long> fd[] = {make_pair(1, 0), make_pair(-1, 0),
                                         make_pair(0, 1), make_pair(0, -1)};
long long n, u, v, da[110000], dt[110000];
vector<long long> g[110000];
bool isPath[110000];
bool dfsA(long long node, long long par) {
  bool ret = false;
  for (long long i = (0); i < (g[node].size()); i++) {
    long long to = g[node][i];
    if (to == par) continue;
    da[to] = da[node] + 1;
    ret = dfsA(to, node) || ret;
  }
  ret = ret || (node == u);
  if (ret) isPath[node] = true;
  return ret;
}
void dfsT(long long node, long long par) {
  for (long long i = (0); i < (g[node].size()); i++) {
    long long to = g[node][i];
    if (to == par) continue;
    dt[to] = dt[node] + 1;
    dfsT(to, node);
  }
}
long long ans = 0;
signed main() {
  cin >> n >> u >> v;
  u--;
  v--;
  for (long long i = (0); i < (n - 1); i++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfsA(v, -1);
  dfsT(u, -1);
  long long node, mx = -1;
  ans = da[u] - 1;
  for (long long i = (0); i < (n); i++) {
    if (!isPath[i] && da[i] > dt[i]) {
      chmax(ans, dt[i] + (da[i] - dt[i]) / 2);
    }
  }
  cout << ans << endl;
}
