#include <bits/stdc++.h>
#pragma warning(disable : 4996)
const long long MOD = 1000000007;
using namespace std;
vector<vector<int> > g;
vector<int> d;
vector<int> maxd;
vector<int> up;
int dfs(int par, int curr, int depth_curr) {
  d[curr] = depth_curr;
  up[curr] = par;
  int siz = (int)g[curr].size();
  int max = depth_curr;
  int i;
  for (i = 0; i < siz; i++) {
    int next = g[curr][i];
    if (next == par) continue;
    int ret = dfs(curr, next, depth_curr + 1);
    max = ((ret) < (max) ? (max) : (ret));
  }
  return maxd[curr] = max;
}
int main(int argc, char* argv[]) {
  int n, u, v;
  scanf("%d%d%d", &n, &u, &v);
  u--;
  v--;
  g.resize(n);
  d.resize(n);
  maxd.resize(n);
  up.resize(n);
  int i;
  for (i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(-1, v, 0);
  int curr = u;
  for (i = 0; i < d[u] / 2; i++) {
    u = up[u];
  }
  printf("%d\n", maxd[u] - 1);
  return 0;
}
