#include<iostream>
#include<algorithm>
#include<vector>
#include<climits>

using namespace std;

static const int MAX = 100;
static const long long INFINITY = (1LL<<32);

int n;
long long d[MAX][MAX];

void floyd(){
  for (int k=0;k<n;k++){
  for (int i=0;i<n;i++){
    if (d[i][k]==INFINITY) continue;
    for (int j=0;j<n;j++){
      if (d[k][j]==INFINITY) continue;
      d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      d[j][i] = d[i][j];
      
    }
  }
  } 
}

int main(){
  int u, v;
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i=0;i<n;i++){
    for (int j=0;j<n;j++){
      d[i][j] = ((i==j) ? 0 : INFINITY);
    }
  }

  for (int i=0;i<n-1;i++){
    int a;
    int b;
    cin >> a >> b;
    a--;
    b--;
    d[a][b] = 1;
    d[b][a] = 1;
  }
  floyd();  

  int cnt = 0;
  while (1){
    //cout << u+1 << " "<<v+1<<" "<<n<<endl;
    if (u==v) break;

    cnt++;
    int tmp_max = 0;
    int tmp_min = MAX;
    int tmp_max_in = 0;
    int tmp_min_in = 0;
    for (int i=0;i<n;i++){
      if (d[u][i] ==1) {
	if(cnt==3){
	  //cout << "a"<<u<<" " << i<<" "<<d[i][v]<<tmp_max<<endl;
	}
	if (tmp_max<=d[v][i]){
	  tmp_max = d[v][i];
	  tmp_max_in = i;
	}
      }

    }
    //if(cnt==3) cout << tmp_max_in<<" ss";
    u = tmp_max_in;
    if (u==v) break;
    //cout << u+1 << " "<<v+1<<" "<<n<<endl;

      for (int j=0;j<n;j++){

      if (d[v][j] ==1) {
	if (tmp_min>d[u][j]){
	  tmp_min = d[u][j];	  
	  tmp_min_in = j;
	}
      }
      }
      v = tmp_min_in;
      if (u==v) break;

  }
  cout << cnt << endl;
}

