#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
int gcd(int a, int b) {
  if (a < b) gcd(b, a);
  if (b == 0)
    return a;
  else
    gcd(b, a % b);
}
const int INF = 1 << 30;
const int MOD = 1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
int n, u, v;
vector<int> g[100005];
void dfs(int now, vector<int> &vec, int step) {
  if (vec[now] != -1) return;
  vec[now] = step;
  for (auto to : g[now]) {
    if (to == now) continue;
    dfs(to, vec, step + 1);
  }
}
int main() {
  cin >> n >> u >> v;
  u--;
  v--;
  vector<int> a_step(n, -1), b_step(n, -1);
  for (int i = 0; i < (n); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(u, a_step, 0);
  dfs(v, b_step, 0);
  int ans = 0;
  for (int i = 0; i < (n); i++) {
    if (a_step[i] < b_step[i]) chmax(ans, b_step[i]);
  }
  ans--;
  printf("%d\n", ans);
  return 0;
}
