#include <bits/stdc++.h>
using namespace std;
const long long INF = 2e18;
const long long MOD = 1e9 + 7;
long long N, u, v;
long long depth[100010];
long long par[100010];
vector<long long> edges[100010];
void SetDepth(long long v) {
  depth[v] = depth[par[v]] + 1;
  for (auto e : edges[v]) {
    if (depth[e] == INF) {
      par[e] = v;
      SetDepth(e);
    }
  }
}
long long MaxDepth(long long v) {
  long long ret = depth[v];
  for (auto e : edges[v]) {
    if (e != par[v]) {
      ret = max(ret, MaxDepth(e));
    }
  }
  return ret;
}
int main() {
  cin >> N >> u >> v;
  for (long long i = 0; i < N - 1; i++) {
    long long a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  for (long long i = 1; i <= N; i++) {
    depth[i] = INF;
  }
  depth[0] = -1;
  par[v] = 0;
  SetDepth(v);
  long long n = u;
  long long upCnt = (depth[u] - 1) / 2;
  for (long long i = 0; i < upCnt; i++) {
    n = par[n];
  }
  cout << upCnt + (MaxDepth(n) - depth[n]) + (depth[u] % 2 ? 0 : 1) << endl;
  cout << "---------" << endl;
  return 0;
}
