#include <bits/stdc++.h>
using namespace std;
const int INF = (0x7FFFFFFFL);
const long long INFF = (0x7FFFFFFFFFFFFFFFL);
const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int MOD = 1e9 + 7;
const int MODD = 998244353;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const double PI = acos(-1.0);
const double EPS = 1e-9;
const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int dy[9] = {0, 1, 0, -1, -1, -1, 1, 1, 0};
template <typename T>
void MACRO_VAR_Scan(T &t) {
  cin >> t;
}
template <typename First, typename... Rest>
void MACRO_VAR_Scan(First &first, Rest &...rest) {
  cin >> first;
  MACRO_VAR_Scan(rest...);
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &j) {
  o << "{" << j.first << ", " << j.second << "}";
  return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const multiset<T> &j) {
  o << "{";
  for (auto t = j.begin(); t != j.end(); ++t)
    o << (t != j.begin() ? ", " : "") << *t;
  o << "}";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &j) {
  o << "{";
  for (int i = 0; i < (int)j.size(); ++i) o << (i > 0 ? ", " : "") << j[i];
  o << "}";
  return o;
}
inline int print(void) {
  cout << endl;
  return 0;
}
template <class Head>
int print(Head &&head) {
  cout << head;
  print();
  return 0;
}
template <class Head, class... Tail>
int print(Head &&head, Tail &&...tail) {
  cout << head << " ";
  print(forward<Tail>(tail)...);
  return 0;
}
template <typename T>
void PA(T &a) {
  int ASIZE = sizeof(a) / sizeof(a[0]);
  for (int ii = 0; ii < ASIZE; ++ii) {
    cout << a[ii] << " \n"[ii == ASIZE - 1];
  }
}
template <typename T>
void PV(T &v) {
  int VSIZE = v.size();
  for (int ii = 0; ii < VSIZE; ++ii) {
    cout << v[ii] << " \n"[ii == VSIZE - 1];
  }
}
inline int YES(bool x) {
  cout << ((x) ? "YES" : "NO") << endl;
  return 0;
}
inline int Yes(bool x) {
  cout << ((x) ? "Yes" : "No") << endl;
  return 0;
}
inline int yes(bool x) {
  cout << ((x) ? "yes" : "no") << endl;
  return 0;
}
inline int yES(bool x) {
  cout << ((x) ? "yES" : "nO") << endl;
  return 0;
}
inline int Yay(bool x) {
  cout << ((x) ? "Yay!" : ":(") << endl;
  return 0;
}
template <typename A, typename B>
void sankou(bool x, A a, B b) {
  cout << ((x) ? (a) : (b)) << endl;
}
inline long long MOP(long long x, long long n, long long m = MOD) {
  long long r = 1;
  while (n > 0) {
    if (n & 1) (r *= x) %= m;
    (x *= x) %= m;
    n >>= 1;
  }
  return r;
}
inline long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
inline long long POW(long long a, long long b) {
  long long c = 1ll;
  do {
    if (b & 1) c *= 1ll * a;
    a *= 1ll * a;
  } while (b >>= 1);
  return c;
}
template <typename T, typename A, typename B>
inline bool between(T x, A a, B b) {
  return ((a <= x) && (x < b));
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <typename A, typename B>
inline bool chmax(A &a, const B &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename A, typename B>
inline bool chmin(A &a, const B &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct abracadabra {
  abracadabra() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(5);
  };
} ABRACADABRA;
struct HLD {
  static const int MAXLOG = 20;
  int V, E = 0;
  vector<int> dep, sz, pathidx, child, idx;
  vector<vector<int>> edge, paths, dbl;
  HLD(int V) : V(V) {
    edge.resize(V);
    paths.resize(V);
    dep = sz = pathidx = child = idx = vector<int>(V, 0);
    dbl.resize(MAXLOG + 1, vector<int>(V, 0));
  }
  void add_edge(int a, int b) {
    edge[a].emplace_back(b);
    edge[b].emplace_back(a);
    ++E;
  }
  void dfs(int cur, int prv) {
    dbl[0][cur] = prv;
    sz[cur] = 1;
    child[cur] = idx[cur] = -1;
    pathidx[cur] = cur;
    dep[cur] = (prv == -1) ? 0 : (dep[prv] + 1);
    for (int i = 0; i < edge[cur].size(); ++i)
      if (edge[cur][i] != prv) {
        int nxt = edge[cur][i];
        dfs(nxt, cur);
        sz[cur] += sz[nxt];
        if (child[cur] == -1 or sz[nxt] > sz[child[cur]]) {
          child[cur] = nxt;
          idx[cur] = i;
        }
      }
  }
  void dfs2(int cur, int prv) {
    if (prv != -1 and child[prv] == cur) pathidx[cur] = pathidx[prv];
    paths[pathidx[cur]].emplace_back(cur);
    for (auto &nxt : edge[cur])
      if (nxt != prv) dfs2(nxt, cur);
  }
  int lca(int u, int v) {
    if (dep[u] > dep[v]) swap(u, v);
    for (int i = MAXLOG - 1; i >= 0; --i)
      if (dep[v] - dep[u] >= 1 << i) v = dbl[i][v];
    for (int i = MAXLOG - 1; i >= 0; --i)
      if (dbl[i][u] != dbl[i][v]) {
        u = dbl[i][u];
        v = dbl[i][v];
      }
    return (u == v) ? u : dbl[0][u];
  }
  void build(int root = 0) {
    dfs(root, root);
    dfs2(root, root);
    for (int i = 0; i < MAXLOG; ++i) {
      for (int j = 0; j < V; ++j) {
        dbl[i + 1][j] = dbl[i][dbl[i][j]];
      }
    }
  }
};
const int MAXN = 100100;
HLD hld(MAXN);
vector<vector<int>> graph;
int takahashi(int, int, int);
int aoki(int, int, int);
int dist(int, int);
map<pair<int, int>, int> memo1;
int takahashi(int tak, int aok, int prvtak = -1) {
  if (memo1.count(make_pair(tak, aok)) != 0) {
    return memo1[make_pair(tak, aok)];
  }
  if (tak == aok) return 0;
  int ret = 0;
  for (auto &nxt : graph[tak]) {
    if (nxt == prvtak) continue;
    if (nxt == aok) continue;
    int cur = dist(nxt, aok);
    for (auto &nxt2 : graph[aok]) {
      if (cur > dist(nxt, nxt2)) {
        chmax(ret, takahashi(nxt, nxt2, tak) + 1);
        break;
      }
    }
  }
  return memo1[make_pair(tak, aok)] = ret;
}
map<pair<int, int>, int> lll;
int dist(int a, int b) {
  if (lll.count(make_pair(a, b))) return lll[make_pair(a, b)];
  int lca = hld.lca(a, b);
  return lll[make_pair(a, b)] = hld.dep[a] + hld.dep[b] - 2 * hld.dep[lca];
}
signed main() {
  int N, U, V;
  MACRO_VAR_Scan(N, U, V);
  ;
  --U, --V;
  graph.resize(N);
  for (long long i = long long(0); i < long long(N - 1); ++i) {
    int A, B;
    MACRO_VAR_Scan(A, B);
    ;
    --A, --B;
    graph[A].emplace_back(B);
    graph[B].emplace_back(A);
    hld.add_edge(A, B);
  }
  hld.build();
  print(takahashi(U, V));
}
