#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) {
  if (!y) return x;
  return gcd(y, x % y);
}
long long expo(int a, int b) {
  long long result = 1;
  while (b) {
    if (b & 1) {
      result *= a;
    }
    b >>= 1;
    a *= a;
  }
  return result;
}
vector<long long> vec[1005];
long long n, m, s, t;
long long diss[1005];
long long dist[1005];
long long edge[1005][1005];
void bfss(long long s) {
  diss[s] = 0;
  queue<long long> q;
  q.push(s);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (auto v : vec[u]) {
      if (diss[v] == -1) {
        diss[v] = diss[u] + 1;
        q.push(v);
      }
    }
  }
}
void bfst(long long t) {
  dist[t] = 0;
  queue<long long> q;
  q.push(t);
  while (!q.empty()) {
    long long u = q.front();
    q.pop();
    for (auto v : vec[u]) {
      if (dist[v] == -1) {
        dist[v] = dist[u] + 1;
        q.push(v);
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long test = 1;
  while (test--) {
    cin >> n >> m >> s >> t;
    memset(edge, 0, sizeof(edge));
    memset(dist, -1, sizeof(dist));
    memset(diss, -1, sizeof(diss));
    for (long long i = 0; i < m; i++) {
      long long x, y;
      cin >> x >> y;
      vec[x].push_back(y);
      vec[y].push_back(x);
      edge[x][y] = 1;
      edge[y][x] = 1;
    }
    bfss(s);
    bfst(t);
    long long cnt = 0;
    long long d = diss[t];
    for (long long i = 1; i <= n; i++) {
      for (long long j = i + 1; j <= n; j++) {
        if (edge[i][j] == 0 &&
            (diss[i] + 1 + dist[j] >= d && diss[j] + 1 + dist[i] >= d)) {
          cnt++;
          edge[i][j] = 1;
          edge[j][i] = 1;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}
