#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void self_max(int &a, int b) { a = max(a, b); }
void self_min(int &a, int b) { a = min(a, b); }
int n;
vector<int> to[100005];
std::vector<int> dist;
void dfs(int v, int d = 0, int P = -1) {
  dist[v] = d;
  for (int u : to[v]) {
    if (u == v) continue;
    dfs(u, d + 1, v);
  }
}
vector<int> calDistance(int P) {
  dist = vector<int>(n);
  dfs(P);
  return dist;
}
int main() {
  cin >> n;
  int T, A;
  cin >> T >> A;
  --T;
  --A;
  for (int i = 0; i < (n - 1); ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  vector<int> distFromA = calDistance(A);
  vector<int> distFromT = calDistance(T);
  int ret = 0;
  for (int i = 0; i < (n); ++i) {
    if (distFromA[i] > distFromT[i]) {
      self_max(ret, distFromA[i]);
    }
  }
  int ans = ret - 1;
  cout << ans << endl;
  return 0;
}
