#include <stdio.h>
#include <stdlib.h>

typedef struct node
{
  int depth;
  int parent;
  int num_child;
  int *child;
} Node;

int main()
{
  int n, u, v, a, b;
  scanf("%d %d %d",&n, &u, &v);
  
  Node *nodes = (Node*)malloc(sizeof(Node)*n);
  for (int i = 0; i < n; ++i) {
    nodes[i].depth = n+1;
    nodes[i].num_child = 0;
    nodes[i].child = (int*)malloc(sizeof(int)*n);
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d %d", &a, &b);
    if (nodes[a-1].depth < nodes[b-1].depth) {
      nodes[a-1].child[nodes[a-1].num_child] = b-1;
      nodes[a-1].num_child++;
      if (nodes[a-1].depth == n+1)
        nodes[a-1].depth = 0;
      else
        nodes[a-1].depth++;
      
      if (nodes[b-1].depth == n+1)
        nodes[b-1].depth = nodes.[a-1].depth + 1;
    }
    else {
      nodes[b-1].child[nodes[b-1].num_child] = a-1;
      nodes[b-1].num_child++;
      if (nodes[b-1].depth == n+1)
        nodes[b-1].depth = 0;
      else
        nodes[b-1].depth++;
      
      if (nodes[a-1].depth == n+1)
        nodes[a-1].depth = nodes.[b-1].depth + 1;
    }
  }
  printf("%d\n",nodes[u-1].depth - nodes[v-1].depth);
}
