#include <bits/stdc++.h>
template <class T>
bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int, int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
void dfs(const vvint g, vint &dis, int v, int p = -1) {
  for (int n_v : g[v]) {
    if (n_v == p) continue;
    dis[n_v] = dis[v] + 1;
    dfs(g, dis, n_v, v);
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  vvint g(n);
  for (int i = 0; i < (int)(n - 1); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vint dis_u(n, inf);
  vint dis_v(n, inf);
  dis_u[u] = 0;
  dis_v[v] = 0;
  dfs(g, dis_u, u);
  dfs(g, dis_v, v);
  int ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (dis_u[i] < dis_v[i]) {
      ans = max(ans, dis_v[i] - 1);
    }
  }
  cout << ans << endl;
}
