#include <bits/stdc++.h>
using namespace std;
struct edge {
  struct treev* to;
  long long length;
};
struct treev {
  int num;
  vector<edge> nexts;
};
int u, v;
vector<treev*> vs;
treev* createtreenode(int num) {
  treev* newt = new treev;
  if (newt == NULL) {
    cout << "memory error" << endl;
    while (1) {
      num = 1;
    }
  }
  newt->num = num;
  newt->nexts = {};
  return newt;
}
void insertree(long long len, int Va, int Vb) {
  vs[Va]->nexts.push_back({vs[Vb], len});
  vs[Vb]->nexts.push_back({vs[Va], len});
  return;
}
vector<int> udepth;
vector<int> vdepth;
void DFS1(treev* root, long long depth, treev* pre) {
  udepth[root->num] = depth;
  for (auto i : root->nexts) {
    if (pre == i.to) {
      continue;
    }
    DFS1(i.to, depth + 1, root);
  }
  return;
}
vector<int> scan;
void DFS2(treev* root, long long depth, treev* pre) {
  vdepth[root->num] = depth;
  for (auto i : root->nexts) {
    if (pre == i.to) {
      continue;
    }
    DFS2(i.to, depth + 1, root);
  }
  return;
}
void DFS3(treev* root, long long depth, treev* pre) {
  if (depth != 0 && root->num != v) {
    scan[root->num] = 1;
  }
  for (auto i : root->nexts) {
    if (pre == i.to) {
      continue;
    }
    if (vdepth[root->num] < vdepth[i.to->num]) continue;
    DFS3(i.to, depth + 1, root);
  }
  return;
}
int main(void) {
  int n;
  cin >> n >> u >> v;
  for (int i = 0; i < n; i++) {
    vs.push_back(createtreenode(i));
  }
  scan = vector<int>(n, 0);
  vector<int> a(n - 1);
  vector<int> b(n - 1);
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  for (int i = 0; i < n - 1; i++) {
    insertree(1, a[i], b[i]);
  }
  u--;
  v--;
  udepth = vector<int>(n, 0);
  vdepth = vector<int>(n, 0);
  DFS1(vs[u], 0, NULL);
  DFS2(vs[v], 0, NULL);
  DFS3(vs[u], 0, NULL);
  int distance = udepth[v];
  int maxover = 0;
  for (int i = 0; i < n; i++) {
    if (udepth[i] < vdepth[i]) {
      maxover = max(maxover, udepth[i]);
    }
  }
  int ans = 0;
  int scannum = 0;
  for (int i = 0; i < n; i++) {
    if (scan[i] == 1) {
      scannum++;
    }
  }
  distance -= scannum;
  while (distance > 0) {
    if (maxover == 0) {
      maxover += 1;
      distance -= 2;
      if (distance == 0) {
        break;
      }
    } else {
      maxover -= 1;
    }
    ans += 1;
  }
  cout << ans - 1 << endl;
  return 0;
}
