#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
using tll = tuple<ll, ll, ll>;
using vtll = vector<tll>;
using vvtll = vector<vtll>;
template <typename Head>
void dump_1(const char* str, Head&& h) {
  cerr << str << ": " << h << '\n';
}
template <typename Head, typename... Tail>
void dump_1(const char* str, Head&& h, Tail&&... t) {
  while (*str != ',') {
    cerr << *str++;
  }
  cerr << ": " << h << ' ';
  dump_1(str + 1, t...);
}
template <typename T>
void dumpa_1(const char* str, const T v[], const ll size) {
  while (*str != ',') {
    cerr << *str++;
  }
  cerr << ": ";
  for (ll i = 0; i < (size); i++) {
    if (i != 0) {
      cerr << ' ';
    }
    cerr << v[i];
  }
  cerr << '\n';
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& v) {
  os << v.first << ' ' << v.second;
  return os;
}
template <typename T1, typename T2, typename T3>
ostream& operator<<(ostream& os, const tuple<T1, T2, T3>& v) {
  os << get<0>(v) << ' ' << get<1>(v) << ' ' << get<2>(v);
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) {
      os << ' ';
    }
    os << *it;
  }
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v) {
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) {
      os << ' ';
    }
    os << *it;
  }
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& v) {
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) {
      os << ' ';
    }
    os << *it;
  }
  return os;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const map<T1, T2>& v) {
  os << '{';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) {
      os << ", ";
    }
    os << it->first << ':' << it->second;
  }
  os << '}';
  return os;
}
void Yes(void) { cout << "Yes\n"; }
void No(void) { cout << "No\n"; }
void YES(void) { cout << "YES\n"; }
void NO(void) { cout << "NO\n"; }
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
void vin(vector<T>& v, ll len) {
  for (ll i = 0; i < (len); i++) {
    cin >> v[i];
  }
}
template <typename Head>
void in_1(Head& h) {
  cin >> h;
}
template <typename Head, typename... Tail>
void in_1(Head& h, Tail&... t) {
  cin >> h;
  in_1(t...);
}
template <typename Head>
void print_1(Head&& h) {
  cout << h << '\n';
}
template <typename Head, typename... Tail>
void print_1(Head&& h, Tail&&... t) {
  cout << h << ' ';
  print_1(t...);
}
void dfs(int pos, int pre, int step, vector<vector<int>>& to, vector<int>& vh) {
  vh[pos] = step;
  for (int t : to[pos]) {
    if (t != pre) {
      dfs(t, pos, step + 1, to, vh);
    }
  }
}
ll ans = 0;
void dfs2(int pos, int pre, int step, vector<vector<int>>& to, vector<int>& vh,
          vector<int>& uh) {
  uh[pos] = step;
  if (vh[pos] <= step) {
    if (ans < vh[pos]) {
      ans = vh[pos];
    }
    return;
  }
  for (int t : to[pos]) {
    if (uh[t] < step + 10) {
      dfs2(t, pos, step + 1, to, vh, uh);
    }
  }
}
void solve() {
  int N, U, V;
  in_1(N, U, V);
  --U;
  --V;
  vector<int> uh(N);
  vector<int> vh(N);
  vector<vector<int>> to(N);
  for (ll i = 0; i < (N - 1); i++) {
    int a, b;
    in_1(a, b);
    --a;
    --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  dfs(V, -1, 0, to, vh);
  dfs2(U, -1, 0, to, vh, uh);
  print_1(ans);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  cerr << fixed << setprecision(16);
  solve();
}
