#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.141592653589793238463;
const int N = 1010;
const long long INF = 1LL << 60;
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
vector<int> g[N];
bool visA[N];
bool visT[N];
long long distA[N];
long long distT[N];
void dfsA(int curr, int par, int dist) {
  distA[curr] = dist;
  visA[curr] = 1;
  for (auto x : g[curr]) {
    if (visA[x] == 0) {
      dfsA(x, curr, dist + 1);
    } else {
      if (distA[x] > (distA[curr] + 1)) {
        dfsA(x, curr, dist + 1);
      }
    }
  }
}
void dfsT(int curr, int par, int dist) {
  distT[curr] = dist;
  visT[curr] = 1;
  for (auto x : g[curr]) {
    if (visT[x] == 0) {
      dfsT(x, curr, dist + 1);
    } else {
      if (distT[x] > (distT[curr] + 1)) {
        dfsT(x, curr, dist + 1);
      }
    }
  }
}
int main() {
  int n, u, v;
  cin >> n >> u >> v;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfsA(v, -1, 0);
  dfsT(u, -1, 0);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (distA[i] > distT[i]) {
      chmax(ans, distA[i] - 1);
    }
  }
  cout << ans << endl;
}
