#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1},
          Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
struct edge {
  int to, cost;
};
int n, u, v;
vector<vector<int> > a(100000);
vector<bool> used(100000, false);
vector<bool> usedt(100000, false);
int depa[100000];
int dept[100000];
void dfsa(int node, int d) {
  depa[node] = d;
  used[node] = true;
  for (int i = 0; i < a[node].size(); i++) {
    if (used[a[node][i]]) continue;
    dfsa(a[node][i], d + 1);
  }
}
void dfst(int node, int d) {
  dept[node] = d;
  usedt[node] = true;
  for (int i = 0; i < a[node].size(); i++) {
    if (usedt[a[node][i]]) continue;
    dfst(a[node][i], d + 1);
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> u >> v;
  u--;
  v--;
  for (int i = 0; i < n - 1; i++) {
    int temp, temp1;
    cin >> temp >> temp1;
    temp--;
    temp1--;
    a[temp].push_back(temp1);
    a[temp1].push_back(temp);
  }
  dfsa(v, 0);
  dfst(u, 0);
  int ans = -1;
  int ansi = 0;
  for (int i = 0; i < n; i++) {
    if (depa[i] > dept[i]) {
      if (ans < dept[i]) {
        ansi = i;
        ans = dept[i];
      }
    }
  }
  cout << depa[ansi] - 1 << "\n";
}
