#include <bits/stdc++.h>
using namespace std;
struct XX {
  long long a;
  int iro;
};
class xxGreater {
 public:
  bool operator()(const XX& riLeft, const XX& riRight) const {
    if ((riLeft.a) == (riRight.a)) {
      return riLeft.iro < riRight.iro;
    }
    return (riLeft.a) > (riRight.a);
  }
};
vector<int> G[100000];
int t[100000];
int a[100000];
bool use[100000];
void dfsa(int s, int cnt) {
  if (use[s]) return;
  use[s] = true;
  a[s] = cnt;
  cnt++;
  for (int i = 0; i < G[s].size(); i++) {
    dfsa(G[s][i], cnt);
  }
}
void dfst(int s, int cnt) {
  if (use[s]) return;
  use[s] = true;
  t[s] = cnt;
  cnt++;
  for (int i = 0; i < G[s].size(); i++) {
    if (a[G[s][i]] > cnt) {
      dfst(G[s][i], cnt);
    } else if (a[G[s][i]] == cnt) {
      use[G[s][i]] = true;
      t[G[s][i]] = cnt;
    }
  }
}
int main(int argc, const char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, u, v;
  cin >> N >> u >> v;
  u--;
  v--;
  for (int i = 0; i < N - 1; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    t1--;
    t2--;
    G[t1].push_back(t2);
    G[t2].push_back(t1);
  }
  dfsa(v, 0);
  for (int i = 0; i < N; i++) {
    use[i] = false;
  }
  dfst(u, 0);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (t[i] != 0) {
      ans = max(ans, a[i]);
    }
  }
  if ((ans + 1) % 2 != 0) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
