#include <bits/stdc++.h>
using namespace std;
vector<int> edge[1005];
int vis[2][1005];
int d[2][1005];
int adj[1005][1005];
void djikstra(int s, int id) {
  priority_queue<pair<int, int> > PQ;
  PQ.push(make_pair(0, s));
  d[id][s] = 0;
  while (!PQ.empty()) {
    pair<int, int> p = PQ.top();
    PQ.pop();
    int v = p.second;
    int cd = -p.first;
    if (cd != d[id][v] || vis[id][v]) continue;
    vis[id][v] = 1;
    for (int i = 0; i < edge[v].size(); i++) {
      int u = edge[v][i];
      int nd = cd + 1;
      if (!vis[id][u] && nd < d[id][u]) {
        d[id][u] = nd;
        PQ.push(make_pair(-nd, u));
      }
    }
  }
}
int main() {
  int n, m, s, t;
  scanf("%d%d%d%d", &n, &m, &s, &t);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
    adj[u][v] = adj[v][u] = 1;
  }
  for (int i = 1; i <= n; i++) {
    d[0][i] = d[1][i] = n;
  }
  djikstra(s, 0);
  djikstra(t, 1);
  int th = d[0][t];
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (adj[i][j]) continue;
      int dist = min(d[0][i] + d[1][j], d[0][j] + d[1][i]);
      if (dist + 1 >= th) ans++;
    }
  }
  printf("%d\n", ans);
}
