#include <bits/stdc++.h>
using namespace std;
int n, m, s, t;
const int maxn = 1e3 + 5;
vector<int> edge[maxn];
vector<int> ds(maxn, maxn);
vector<int> dt(maxn, maxn);
void bfs(int st, vector<int> &dis) {
  queue<pair<int, int> > que;
  dis[st] = 0;
  que.emplace(st, 0);
  while (!que.empty()) {
    auto top = que.front();
    que.pop();
    for (auto &i : edge[top.first]) {
      if (dis[i] > top.second + 1) {
        dis[i] = top.second + 1;
        que.emplace(i, dis[i]);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(15);
  cout << fixed;
  cin >> n >> m >> s >> t;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  for (int i = 1; i <= n; i++) sort((edge[i]).begin(), (edge[i]).end());
  bfs(s, ds);
  bfs(t, dt);
  int ans = n * (n - 1) / 2 - m;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (ds[i] + 1 + dt[j] < ds[t] || ds[j] + 1 + dt[i] < dt[s]) {
        ans--;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
