#include <bits/stdc++.h>
using namespace std;
long long n, cnt, a, b;
int dian[1000005], m;
vector<int> bian[1000005];
long long xxx(long long x) {
  if (x < 2) return 0;
  return x * (x - 1) / 2;
}
void bfs(int u, int l) {
  dian[u] = l;
  for (int i = 0; i < bian[u].size(); i++) {
    int v = bian[u][i];
    if (dian[v] == 0) bfs(v, ++l);
    if (dian[u] - dian[v] == 2) b++;
  }
}
int main() {
  scanf("%lld%d", &n, &m);
  if (n < 3) {
    printf("0\n");
    return 0;
  }
  cnt = n * (n - 1) * (n - 2) / 6 - m * (n - 2);
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    bian[x].push_back(y);
    bian[y].push_back(x);
  }
  a = 0, b = 0;
  for (int i = 1; i <= n; i++) {
    a += xxx(bian[i].size());
    if (dian[i] == 0) bfs(i, 1);
  }
  a -= b * 3;
  cnt += a + b * 3;
  cout << cnt << endl;
  return 0;
}
