structedge { int to, nxt; }e[maxm << 1]; int n, m, ptr, lnk[maxn]; int id[maxn], sza, szb, szr, fre, toa, tob;
inlinevoidadd(int bgn, int end){ e[++ptr] = (edge){end, lnk[bgn]}; lnk[bgn] = ptr; } inlineintrd(){ registerint x = 0, c = getchar(); while (!isdigit(c)) c = getchar(); while (isdigit(c)) x = x * 10 + (c ^ 48), c = getchar(); return x; }
intmain(){ n = rd(); m = rd(); int u, v; for (int i = 1; i <= m; ++i) { u = rd(); v = rd(); add(u, v); add(v, u); } for (int p = lnk[1]; p; p = e[p].nxt) { int y = e[p].to; id[y] = 1; sza++; } for (int p = lnk[2]; p; p = e[p].nxt) { int y = e[p].to; id[y] = 2; szb++; } int res = n - sza - szb - 2; int ans = sza * (sza - 1) / 2 + szb * (szb - 1) / 2 + res * (res - 1) / 2 + sza + szb; for (int i = 3; i <= n; ++i) if (!id[i]) { for (int p = lnk[i]; p; p = e[p].nxt) { int y = e[p].to; if (id[y] == 1) toa++; elseif (id[y] == 2) tob++; if(id[y]) break; } } fre = res - toa - tob; ans += toa * sza + tob * szb + fre * max(sza, szb); ans = ans - m; printf("%d\n", ans); return0; }