#include <bits/stdc++.h>
using namespace std;
inline void pilot() {
  ios::sync_with_stdio(false);
  cin.tie(0);
}
const int N = 5005;
vector<int> g[N];
int dist[2][N];
bitset<N> vs[N];
void bfs(int idx, int s) {
  queue<pair<int, int> > q;
  q.push({s, 0});
  bitset<N> vis;
  vis[s] = 1;
  dist[idx][s] = 0;
  bool ok = false;
  while (!q.empty()) {
    auto u = q.front();
    q.pop();
    for (auto p : g[u.first]) {
      if (dist[idx][p] == -1) {
        dist[idx][p] = u.second + 1;
        q.push({(int)p, u.second + 1});
      }
    }
  }
}
int main() {
  pilot();
  int n, m, s, t;
  cin >> n >> m >> s >> t;
  for (int i = int(1); i < int(n + 1); ++i) dist[0][i] = dist[1][i] = -1;
  while (m--) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    vs[a][b] = 1;
    vs[b][a] = 1;
    g[b].push_back(a);
  }
  bfs(0, s);
  bfs(1, t);
  int D = dist[0][t];
  int DD = dist[1][s];
  int cnt = 0;
  for (int a = int(1); a < int(n + 1); ++a)
    for (int b = int(1); b < int(n + 1); ++b) {
      if (a == b) continue;
      if (vs[a][b] == 1 or vs[b][a] == 1) continue;
      if (dist[0][a] + 1 + dist[1][b] >= D and dist[1][a] + dist[0][b] + 1 >= D)
        vs[a][b] = 1, vs[b][a] = 1, cnt++;
    }
  cout << cnt << endl;
}
