#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1000 + 5;
vector<int> G[MAXN];
int d1[MAXN], d2[MAXN];
void bfs(int s) {
  queue<int> q;
  q.push(s);
  memset(d1, -1, sizeof d1);
  d1[s] = 0;
  while (!q.empty()) {
    long long t = q.front();
    q.pop();
    long long x = G[t].size();
    for (int i = 0; i < x; ++i) {
      if (d1[G[t][i]] == -1) {
        d1[G[t][i]] = d1[t] + 1;
        q.push(G[t][i]);
      }
    }
  }
}
long long n, m, s, t, x, y;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m >> s >> t;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    G[--x].push_back(--y);
    G[y].push_back(x);
  }
  bfs(--s);
  for (int i = 0; i <= 1000; ++i) d2[i] = d1[i];
  bfs(--t);
  long long r = -m;
  long long mo = d1[s];
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      r += ((d1[i] + d2[j] >= mo - 1) && (d1[j] + d2[i] >= mo - 1));
  cout << r;
  return 0;
}
