#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 20;
const int inf = 0x3f3f3f3f;
const int modd = 1e9 + 7;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f * x;
}
template <class T>
inline void sc(T &x) {
  char c;
  x = 0;
  while ((c = getchar()) < '0')
    ;
  while (c >= '0' && c <= '9') x = x * 10 + (c - 48), c = getchar();
}
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
inline long long exgcd(long long a, long long b, long long &x, long long &y) {
  long long d;
  (b == 0 ? (x = 1, y = 0, d = a)
          : (d = exgcd(b, a % b, y, x), y -= a / b * x));
  return d;
}
inline long long qpow(long long a, long long n) {
  long long sum = 1;
  while (n) {
    if (n & 1) sum = sum * a % modd;
    a = a * a % modd;
    n >>= 1;
  }
  return sum;
}
inline long long qmul(long long a, long long n) {
  long long sum = 0;
  while (n) {
    if (n & 1) sum = (sum + a) % modd;
    a = (a + a) % modd;
    n >>= 1;
  }
  return sum;
}
inline long long inv(long long a) { return qpow(a, modd - 2); }
int n, Aoka, Taka, mx = 0;
vector<int> vec[maxn];
bool vis[maxn];
int dfs1(int x, int fa, int &len) {
  if (x == Taka) {
    return true;
  }
  for (auto it : vec[x]) {
    if (it == fa) continue;
    vis[it] = 1;
    if (dfs1(it, x, len)) {
      len++;
      return true;
    }
    vis[it] = 0;
  }
  return false;
}
int dfs2(int x, int fa, int len, int step) {
  if (step == len) {
    return x;
  }
  for (auto it : vec[x]) {
    if (it == fa) continue;
    if (vis[it] == 0) continue;
    vis[it] = 0;
    return dfs2(it, x, len, step + 1);
  }
}
void dfs3(int x, int fa, int step) {
  if (step > mx) mx = step;
  for (auto it : vec[x]) {
    if (it == fa) continue;
    if (vis[it]) continue;
    dfs3(it, x, step + 1);
  }
}
int main() {
  scanf("%d%d%d", &n, &Aoka, &Taka);
  for (int i = 1; i <= n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    vec[u].push_back(v);
    vec[v].push_back(u);
  }
  int len = 0;
  dfs1(Aoka, -1, len);
  int ans = (len - 1) / 2;
  int k = dfs2(Aoka, -1, ans, 0);
  dfs3(k, -1, 0);
  if (len == 2 && mx == 0)
    ans = 1;
  else
    ans += mx;
  printf("%d\n", ans);
}
