#include <bits/stdc++.h>
using namespace std;
struct piii {
  long long first, second, th;
  bool operator<(const piii &b) {
    if (first != b.first) return first < b.first;
    if (second != b.second) return second < b.second;
    return th < b.th;
  }
};
int n, s, t;
vector<int> e[100005];
int p[20][100005], lg[100005], d[100005], ch[100005], ch2[100005], h[100005];
void input() {
  cin >> n >> s >> t;
  int u, v;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
}
void init(int u) {
  for (int i = 1; h[u] - (1 << i) > 0; i++) {
    p[i][u] = p[i - 1][p[i - 1][u]];
    lg[u] = i;
  }
}
void dfs(int u) {
  for (int v : e[u])
    if (v != p[0][u]) {
      p[0][v] = u;
      h[v] = h[u] + 1;
      init(v);
      dfs(v);
      d[u] = max(d[u], d[v]);
      if (d[v] > d[ch[u]])
        ch2[u] = ch[u], ch[u] = v;
      else if (d[v] > d[ch2[u]])
        ch2[u] = v;
    }
  d[u]++;
}
int lca(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  for (int i = lg[u]; i >= 0; i--)
    if (h[u] - (1 << i) >= h[v]) {
      u = p[i][u];
    }
  if (u == v) return u;
  for (int i = lg[u]; i >= 0; i--)
    if (p[i][u] != p[i][v]) {
      u = p[i][u];
      v = p[i][v];
    }
  return p[0][u];
}
int main() {
  cout << setprecision(2) << fixed;
  ios::sync_with_stdio(false), cin.tie(0);
  input();
  h[1] = 1;
  dfs(1);
  int cnt = 0, u = s, v = t;
  while (1) {
    if (u == 1 || p[0][u] == v) {
      if (ch[u] == 0) break;
      if (ch[u] == v || ch[u] == p[0][v]) {
        if (ch2[u] == 0) break;
        u = ch2[u];
      } else
        u = ch[u];
    } else if (p[0][u] == p[0][v] || (p[0][u] != 1 && p[0][v] == p[0][u])) {
      if (ch[u] == 0)
        u = p[0][u];
      else
        u = ch[u];
    } else
      u = p[0][u];
    if (u == v) break;
    if (lca(u, v) != v)
      v = p[0][v];
    else
      v = ch[v];
    cnt++;
    if (u == v) break;
  }
  cout << cnt;
  return 0;
}
