#include <bits/stdc++.h>
using namespace std;
static const int INF = INT_MAX;
static const long long LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const long long LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;
const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};
vector<int> Div(int n) {
  vector<int> ret;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}
void dfsao(int pos, int dist);
void dfsta(int pos, int dist);
vector<int> tree[SIZE];
int di[SIZE];
bool vis[SIZE];
int mxdi, mxpos;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int ta, ao;
  cin >> ta >> ao;
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  for (int i = 0; i < SIZE; ++i) di[i] = INF;
  mxpos = ta;
  dfsao(ao, 0);
  mxdi = di[ta];
  dfsta(ta, 0);
  cout << di[mxpos] - 1 << '\n';
  return 0;
}
void dfsao(int pos, int dist) {
  if (di[pos] <= dist) return;
  di[pos] = dist;
  for (int i = 0; i < tree[pos].size(); ++i) {
    dfsao(tree[pos][i], dist + 1);
  }
  return;
}
void dfsta(int pos, int dist) {
  if (di[pos] < dist) return;
  if (mxdi < di[pos]) {
    mxdi = di[pos];
    mxpos = pos;
  }
  for (int i = 0; i < tree[pos].size(); ++i) {
    dfsta(tree[pos][i], dist + 1);
  }
  return;
}
