#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int limit = 100010;
using edge = struct { int to; };
vector<edge> tree[limit];
ll depth[limit];
void dfs(int v, int p, ll d) {
  depth[v] = d;
  for (auto &e : tree[v]) {
    if (e.to == p) continue;
    dfs(e.to, v, d + 1);
  }
}
int main(void) {
  int n;
  cin >> n;
  int u, v;
  cin >> u >> v;
  u--;
  v--;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].push_back({b});
    tree[b].push_back({a});
  }
  long long ans = 0;
  while (u != v) {
    dfs(u, v, 0);
    int nextu;
    int costu = -1;
    for (auto &e : tree[u]) {
      if (depth[e.to] >= costu) {
        nextu = e.to;
        costu = depth[e.to];
      }
    }
    u = nextu;
    if (u == v) break;
    dfs(u, v, 0);
    int nextv;
    int costv = limit;
    for (auto &e : tree[v]) {
      if (depth[e.to] <= costv) {
        nextv = e.to;
        costv = depth[e.to];
      }
    }
    v = nextv;
    ans++;
  }
  cout << ans << endl;
}
