#include <bits/stdc++.h>
using namespace std;
vector<bool> s[100000];
int n;
int bfs(int first, int end) {
  queue<int> q;
  queue<int> qq;
  q.push(first);
  qq.push(0);
  while (q.size() != 0) {
    int x = q.back();
    int y = qq.back();
    if (x == end) {
      return y;
    }
    for (int i = 1; i <= n; i++) {
      if (s[x][i] == true) {
        q.push(i);
        qq.push(y + 1);
      }
    }
  }
}
int main() {
  int a, b;
  cin >> n >> a >> b;
  for (int i = 0; i <= n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      s[i].push_back(false);
    }
  }
  for (int i = 0; i < n - 1; i++) {
    int c, d;
    cin >> c >> d;
    s[c][d] = true;
    s[d][c] = true;
  }
  for (int jkl = 0; jkl < n; jkl++) {
    int max_place;
    int maxn = -1;
    for (int i = 1; i <= n; i++) {
      if (s[i][a] == true) {
        int g = bfs(b, i);
        if (g > maxn) {
          maxn = g;
          max_place = i;
        }
      }
    }
    a = max_place;
    if (a == b) {
      cout << jkl;
      return 0;
    }
    int minn = 1000000;
    int min_place;
    for (int i = 1; i <= n; i++) {
      if (s[i][b] == true) {
        int g = (a, i);
        if (g < minn) {
          minn = g;
          min_place = i;
        }
      }
    }
    b = min_place;
    if (a == b) {
      cout << jkl + 1;
      return 0;
    }
  }
}
