#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> data(100015);
vector<long long> rota(100015, -1);
vector<long long> rotb(100015, -1);
void dfs1(long long x, long long d) {
  rota[x] = d;
  for (long long(i) = long long(0); (i) < long long(data[x].size()); (i)++) {
    if (rota[data[x][i]] == -1) {
      dfs1(data[x][i], d + 1);
    }
  }
}
void dfs2(long long x, long long d) {
  rotb[x] = d;
  for (long long(i) = long long(0); (i) < long long(data[x].size()); (i)++) {
    if (rotb[data[x][i]] == -1) {
      dfs2(data[x][i], d + 1);
    }
  }
}
int main() {
  long long N;
  cin >> N;
  long long A, B;
  cin >> A >> B;
  A--;
  B--;
  for (long long(i) = long long(0); (i) < long long(N); (i)++) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    data[a].emplace_back(b);
    data[b].emplace_back(a);
  }
  dfs1(A, 0);
  dfs2(B, 0);
  long long ans = 0;
  for (long long(i) = long long(0); (i) < long long(N); (i)++) {
    if (rota[i] < rotb[i]) {
      ans = ((ans) > (rotb[i] - 1) ? (ans) : (rotb[i] - 1));
    }
  }
  cout << (ans) << endl;
  return 0;
}
