#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  int g[200][200];
  cin >> N >> M;
  for (int i = 0; i < (M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a][b] = c;
  }
  int res;
  res = 0;
  for (int i = 1; i <= (N); ++i) {
    for (int j = 1; j <= (N); ++j) {
      for (int k = 1; k <= (N); ++k) {
        int d;
        d = g[i][k] + g[k][j];
        if (d < g[i][j]) {
          ++res;
        }
      }
    }
  }
  cout << res << endl;
  int end;
  cin >> end;
  return 0;
}
