#include <bits/stdc++.h>
using namespace std;
long long GCD(long long x, long long y) {
  if (y == 0) return x;
  return GCD(y, x % y);
}
long long LCM(long long x, long long y) { return (x * y) / (GCD(x, y)); }
long long LOGK(long long x, long long k) {
  if (x >= k) return 1 + LOGK(x / k, k);
  return 0;
}
long long MPOW(long long a, long long b, long long m) {
  if (b == 0) return 1;
  long long x = MPOW(a, b / 2, m);
  x = (x * x) % m;
  if (b % 2 == 1) x = (x * a) % m;
  return x;
}
long long MINV(long long a, long long m) { return MPOW(a, m - 2, m); }
class pnc {
  long long FACT_MAX, MODU;
  vector<long long> fact;

 public:
  pnc(long long n, long long m) {
    FACT_MAX = n;
    fact.resize(FACT_MAX);
    MODU = m;
    MFACT_INIT(MODU);
  }
  void MFACT_INIT(long long m) {
    fact[0] = 1;
    for (long long i = 1; i < FACT_MAX; ++i) fact[i] = (i * fact[i - 1]) % MODU;
  }
  long long MFACT(long long n) { return fact[n]; }
  long long PERM(long long n, long long r) {
    return (fact[n] * ::MINV(fact[n - r], MODU)) % MODU;
  }
  long long COMB(long long n, long long r) {
    return (PERM(n, r) * ::MINV(fact[r], MODU)) % MODU;
  }
};
long long ar[3005][3005] = {0};
long long road[3005][3005] = {0};
int main() {
  long long test = 1;
  while (test--) {
    long long n, m;
    cin >> n >> m;
    long long x, y;
    for (long long i = 1; i <= m; i++) {
      cin >> x >> y;
      road[x][y] = 1;
      for (long long j = 1; j <= n; j++) {
        if (road[j][x]) ar[j][y]++;
        if (road[y][j]) ar[x][j]++;
      }
    }
    long long ans = 0;
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        if (ar[i][j] >= 2 && i != j) ans += ((ar[i][j]) * (ar[i][j] - 1) / 2);
      }
    }
    cout << ans;
  }
}
