#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

int n, u, v;
int c1[111111], c2[111111];
vector<int> g[111111];

void rec(int u, int c[], int d) {
  // printf("%d\n", u);
  if (c[u] >= 0) return;
  c[u] = d;
  for (int i = 0; i < int(g[u].size()); i++) {
    rec(g[u][i], c, d + 1);
  }
}

int main(void) {
  int n; scanf("%d%d%d", &n, &u, &v); --u; --v;
  for (int 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);
  }

  memset(c1, -1, sizeof(c1));
  memset(c2, -1, sizeof(c2));

  rec(u, c1, 0);
  rec(v, c2, 0);
  
  int res = 0;
  for (int i = 0; i < n; i++) {
    // printf("%d %d %d\n", i, c1[i], c2[i]);
    if (c1[i] <= c2[i] && g[i].size() != 1) {
      res = max(res, c2[i]);
    }
  }
  printf("%d\n", res);
  return 0;
}
