memset(h, -1, sizeof h); int n, m; cin >> n >> m; for (int i = 1; i <= m; i++) { cin >> u[i] >> v[i]; deg[u[i]]++; deg[v[i]]++; } for (int i = 1; i <= m; i++) { if ((deg[u[i]] == deg[v[i]] && u[i] > v[i]) || deg[u[i]] > deg[v[i]]) swap(u[i], v[i]); add(u[i], v[i]); } int cnt = 0; for (int u = 1; u <= n; u++) { for (int i = h[u]; ~i; i = edges[i].ne) { int j = edges[i].to; st[j] = true; } for (int i = h[u]; ~i; i = edges[i].ne) { int v = edges[i].to; for (int j = h[v]; ~j; j = edges[j].ne) { int w = edges[j].to; if (st[w]) cnt++; } } for (int i = h[u]; ~i; i = edges[i].ne) { int j = edges[i].to; st[j] = false; } } cout << cnt << endl; return0; }