#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
long long INF = 1001001001001;
long long MAX_E = 200050, MAX_V = 100005;
struct edge {
  long long from, to, cost;
};
vector<edge> es(MAX_E);
vector<long long> d1(MAX_V), d2(MAX_V);
long long V, E;
void shortest_path(long long s, vector<long long>& d) {
  for (long long i = 1; i < V + 1; i++) d[i] = INF;
  d[s] = 0;
  while (true) {
    bool update = false;
    for (long long i = 0; i < E; i++) {
      edge e = es[i];
      if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
        d[e.to] = d[e.from] + e.cost;
        update = true;
      }
    }
    if (!update) break;
  }
}
int main() {
  long long n, v, u;
  cin >> n >> u >> v;
  V = n;
  E = 2 * (n - 1);
  long long j = 0;
  for (int i = 0; i < (n - 1); i++) {
    long long a, b;
    cin >> a >> b;
    es[j] = {a, b, 1};
    j++;
    es[j] = {b, a, 1};
    j++;
  }
  shortest_path(v, d1);
  shortest_path(u, d2);
  long long dis = d1[u];
  long long x = 0;
  for (int i = 0; i < (n); i++) {
    if (d1[i + 1] - d2[i + 1] <= 0) continue;
    chmax(x, d1[i + 1]);
  }
  cout << x - 1 << endl;
}
