#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, a, b, c, ans = 0;
  scanf("%d%d", &n, &m);
  vector<vector<int>> v(n), u(n);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    a--;
    b--;
    v[a].push_back(b);
    u[b].push_back(a);
  }
  for (int i = 0; i < n; i++) {
    sort((v[i]).begin(), (v[i]).end());
    sort((u[i]).begin(), (u[i]).end());
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      vector<int> t(v[i].size() + v[j].size());
      auto it = set_intersection(v[i].begin(), v[i].end(), u[j].begin(),
                                 u[j].end(), t.begin());
      c = it - t.begin();
      ans = ans + (c * c - c) / 2;
      t.clear();
      it = set_intersection(u[i].begin(), u[i].end(), v[j].begin(), v[j].end(),
                            t.begin());
      c = it - t.begin();
      ans = ans + (c * c - c) / 2;
    }
  }
  printf("%d", ans);
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t = 1;
  while (t--) {
    solve();
  }
}
