#include <bits/stdc++.h>
using namespace std;
struct qwe {
  int q, l;
} a[100010];
int he[100010], f[100010];
int n, m, p1, p2, p, sum;
void jian(int x, int y) {
  a[++p].q = y;
  a[p].l = he[x];
  he[x] = p;
}
void slove(int x) {
  for (int i = 1; i <= n; i++) f[i] = 0;
  for (int i = he[x]; i; i = a[i].l) {
    for (int j = he[a[i].q]; j; j = a[j].l)
      if (a[j].q != x) f[a[j].q] += 1;
  }
  for (int i = 1; i <= n; i++)
    if (f[i] > 1) sum += f[i] * (f[i] - 1) / 2;
}
int main() {
  scanf("%d%d", &n, &m);
  p = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &p1, &p2);
    jian(p1, p2);
  }
  for (int i = 1; i <= n; i++) slove(i);
  printf("%d", sum);
  return 0;
}
