#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_A() {
  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 bfs_T() {
  int res = 0;
  queue<int> tq;
  tq.push(u);
  fill(cntT, cntT + 100000, -1);
  cntT[u] = 0;
  while (!tq.empty()) {
    int x = tq.front();
    tq.pop();
    res = max(res, cntA[x] - 1);
    for (int i = 0; i < G[x].size(); i++) {
      int to = G[x][i];
      if (cntT[x] + 1 >= cntA[to]) continue;
      if (cntT[to] == -1) {
        cntT[to] = cntT[x] + 1;
        tq.push(to);
      }
    }
  }
  return res;
}
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_A();
  cout << bfs_T() << endl;
  return 0;
}
