#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5;
int n, u, v;
vector<int> to[MAX];
bool visited[MAX];
bool eble[MAX];
int dis[MAX];
void bfs() {
  queue<int> que;
  que.push(v);
  visited[v] = true;
  dis[v] = 0;
  while (!que.empty()) {
    int tmp = que.front();
    que.pop();
    for (int next : to[tmp]) {
      if (!visited[next]) {
        visited[next] = true;
        que.push(next);
        dis[next] = dis[tmp] + 1;
      }
    }
  }
}
void dfs(int tmp) {
  eble[tmp] = true;
  for (int next : to[tmp]) {
    if (!eble[next]) {
      int x = abs(dis[u] - dis[next]), y = abs(dis[v] - dis[next]);
      if (x > y) continue;
      eble[next] = true;
      if (x < y) dfs(next);
    }
  }
}
int main() {
  cin >> n >> u >> v;
  --u;
  --v;
  for (int i = 0; i < (n); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  bfs();
  dfs(u);
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    if (eble[i]) ans = max(ans, dis[i]);
  }
  cout << ans - 1 << endl;
  return 0;
}
