#include <bits/stdc++.h>
using namespace std;
const long long INF =
    sizeof(long long) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const long long MOD = (long long)(1e9) + 7;
using pii = pair<long long, long long>;
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T>
void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  for (long long i = (0); i < (v.size()); i++)
    for (long long j = (0); j < (v[i].size()); j++) {
      if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
        cerr << "INF";
      } else
        cerr << v[i][j];
      cerr << (j == v[i].size() - 1 ? '\n' : ' ');
    }
  cerr << endl;
}
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T, class U>
bool chmax(T &a, U b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using Weight = long long;
using Flow = long long;
struct Edge {
  long long s, d;
  Weight w;
  Flow c;
  long long id;
  Edge(){};
  Edge(long long s, long long d, Weight w = 1) : s(s), d(d), w(w), c(w){};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) {
  return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')');
}
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;
void addArc(Graph &g, long long s, long long d, Weight w = 1) {
  g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, long long a, long long b, Weight w = 1) {
  addArc(g, a, b, w);
  addArc(g, b, a, w);
}
vector<long long> dijkstra(const Graph &g, long long s, Array &dist) {
  long long n = g.size();
  assert(s < n);
  enum { WHITE, GRAY, BLACK };
  vector<long long> color(n, WHITE);
  color[s] = GRAY;
  vector<long long> prev(n, -1);
  dist.assign(n, INF);
  dist[s] = 0;
  using State = tuple<Weight, long long, long long>;
  priority_queue<State, vector<State>, greater<State>> pq;
  pq.emplace(0, s, -1);
  while (pq.size()) {
    Weight d;
    long long v, u;
    tie(d, v, u) = pq.top();
    pq.pop();
    if (dist[v] < d) continue;
    color[v] = BLACK;
    prev[v] = u;
    for (auto &e : g[v]) {
      if (color[e.d] == BLACK) continue;
      if (dist[e.d] > dist[v] + e.w) {
        dist[e.d] = dist[v] + e.w;
        pq.emplace(dist[e.d], e.d, v);
        color[e.d] = GRAY;
      }
    }
  }
  return prev;
}
signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);
  long long N;
  cin >> N;
  long long u, v;
  cin >> u >> v;
  u--, v--;
  Graph g(N);
  for (long long loop = ((0)); loop < ((N - 1)); loop++) {
    long long a, b;
    cin >> a >> b;
    a--, b--;
    addEdge(g, a, b);
  }
  long long ans = 0;
  while (1) {
    vector<long long> du, dv;
    auto prevu = dijkstra(g, u, du);
    auto prevv = dijkstra(g, v, dv);
    ;
    ;
    ;
    ;
    pii p(-1, -1);
    for (long long i = (0); i < (N); i++) {
      if (du[i] < dv[i]) {
        chmax(p, pii(du[i], i));
      }
    };
    if (p.first == 0) {
      if (du[v] == 2) ans++;
      break;
    }
    ans += p.first;
    u = p.second;
    long long tmp = p.second;
    while (dv[tmp] > p.first) {
      tmp = prevv[tmp];
    }
    v = tmp;
    ;
  }
  cout << ans << endl;
  return 0;
}
