#include <bits/stdc++.h>
using namespace std;
static const int MAX = 100;
static const long long INFINITY = (1LL << 32);
int n;
long long d[MAX][MAX];
void floyd() {
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      if (d[i][k] == INFINITY) continue;
      for (int j = 0; j < n; j++) {
        if (d[k][j] == INFINITY) continue;
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        d[j][i] = d[i][j];
      }
    }
  }
}
int main() {
  int u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      d[i][j] = ((i == j) ? 0 : INFINITY);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int a;
    int b;
    cin >> a >> b;
    a--;
    b--;
    d[a][b] = 1;
    d[b][a] = 1;
  }
  floyd();
  int cnt = 0;
  while (1) {
    if (u == v) break;
    int tmp_max = 0;
    int tmp_min = MAX;
    int tmp_max_in = 0;
    int tmp_min_in = 0;
    for (int i = 0; i < n; i++) {
      if (d[u][i] == 1) {
        if (cnt == 3) {
        }
        if (tmp_max <= d[v][i]) {
          tmp_max = d[v][i];
          tmp_max_in = i;
        }
      }
    }
    u = tmp_max_in;
    if (u == v) break;
    for (int j = 0; j < n; j++) {
      if (d[v][j] == 1) {
        if (tmp_min > d[u][j]) {
          tmp_min = d[u][j];
          tmp_min_in = j;
        }
      }
    }
    cnt++;
    v = tmp_min_in;
    if (u == v) break;
  }
  cout << cnt << endl;
}
