#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int MAX = 2e5;
const long long MOD = 1e9 + 7;
const int INF = 1 << 30;
int N;
vector<vector<int> > G;
vector<int> dist;
void dfs(int v, int d = 0, int p = -1) {
  dist[v] = d;
  for (int nv : G[v]) {
    if (nv == p) continue;
    dfs(nv, d + 1, v);
  }
}
vector<int> calcdist(int v) {
  dist = vector<int>(N);
  dfs(v);
  return dist;
}
int main() {
  cin >> N;
  int u, v;
  cin >> u >> v;
  u--;
  v--;
  G.resize(N, vector<int>(0));
  for (int i = 0; i < (int)(N); i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> distu = calcdist(u);
  vector<int> distv = calcdist(v);
  int mv = 0;
  for (int i = 0; i < (int)(N); i++) {
    if (distu[i] < distv[i]) {
      mv = max(mv, distv[i]);
    }
  }
  int ans = mv - 1;
  cout << ans << endl;
}
