#include <bits/stdc++.h>
using namespace std;
const int MN = 1e5 + 7;
const int MD = 1e9 + 7;
const long long BIG_INF = 1e18 + 7;
const int INF = 2147483645;
int n, mark1[MN], mark2[MN];
vector<int> g[MN];
void dfs1(int now, int dis) {
  mark1[now] = dis;
  for (int i = 0; i < g[now].size(); i++) {
    if (mark1[g[now][i]] == -1) {
      dfs1(g[now][i], dis + 1);
    }
  }
}
void dfs2(int now, int dis) {
  mark2[now] = dis;
  for (int i = 0; i < g[now].size(); i++) {
    if (mark2[g[now][i]] == -1) {
      dfs2(g[now][i], dis + 1);
    }
  }
}
int main() {
  memset(mark1, -1, sizeof mark1);
  memset(mark2, -1, sizeof mark2);
  cin >> n;
  int s, e;
  cin >> s >> e;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  s--;
  e--;
  dfs1(s, 0);
  dfs2(e, 0);
  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (mark1[i] > mark2[i]) continue;
    int w = mark2[i];
    if (mark2[i] & 1 != mark1[i] & 1) {
      w--;
    }
    mx = max(mx, w);
  }
  cout << max(0, mx - 1);
}
