#include <bits/stdc++.h>   using namespace std;   set<long long int> adj[3005];   map<long long int, long long int> mq;   long long int done[3005][3005];   int main() {     ios_base::sync_with_stdio(false);     long long int n, m, i, ans = 0;     cin >> n >> m;     for (i = 0; i < m; i++) {       long long int x, y;       cin >> x >> y;       adj[x].insert(y);     }     for (i = 1; i <= n; i++) {       for (auto it : adj[i]) {         for (auto it2 : adj[it]) {           if (mq.find(it2) != mq.end() && it2 != i) {             ans += mq[it2];           }           mq[it2]++;         }       }       mq.clear();     }     cout << ans <<   n ;     return 0;   }   