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