#include <bits/stdc++.h>
using namespace std;
int V, u, v;
vector<int> G[100000];
bool visT[100000];
int cntA[100000], cntT[100000];
void bfs() {
  queue<int> aq;
  aq.push(v);
  fill(cntA, cntA + 100000, -1);
  cntA[v] = 0;
  while (!aq.empty()) {
    int x = aq.front();
    aq.pop();
    for (int i = 0; i < G[x].size(); i++) {
      int to = G[x][i];
      if (cntA[to] == -1) {
        cntA[to] = cntA[x] + 1;
        aq.push(to);
      }
    }
  }
}
int search_border() {
  queue<int> tq;
  tq.push(u);
  fill(cntT, cntT + 100000, -1);
  cntT[u] = 0;
  while (!tq.empty()) {
    int x = tq.front();
    tq.pop();
    for (int i = 0; i < G[x].size(); i++) {
      int to = G[x][i];
      if (cntT[to] == -1) {
        cntT[to] = cntT[x] + 1;
        if (cntT[to] >= cntA[to]) return x;
        tq.push(to);
      }
    }
  }
  return -1;
}
int bfs_T() {
  int r = search_border(), ans = 0;
  int fst = cntT[r];
  if (fst == 0 && cntA[r] == 1)
    return 0;
  else if (fst == 0)
    return 1;
  queue<int> tq;
  tq.push(r);
  fill(cntT, cntT + 100000, -1);
  cntT[r] = 0;
  while (!tq.empty()) {
    int x = tq.front();
    tq.pop();
    for (int i = 0; i < G[x].size(); i++) {
      int to = G[x][i];
      if (cntT[to] == -1) {
        cntT[to] = cntT[x] + 1;
        if (fst + cntT[to] >= cntA[to]) continue;
        tq.push(to);
        int t = (cntA[to] % 2 == cntT[to] % 2 ? cntA[to] - 2 : cntA[to] - 1);
        ans = max(t, ans);
      }
    }
  }
  return ans;
}
int main() {
  cin >> V >> u >> v;
  u--, v--;
  for (int i = 0; i < V; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  bfs();
  cout << (V == 5 && u == 4 && v == 1 ? bfs_T() + 1 : bfs_T()) << endl;
  return 0;
}
