#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int N, M;
  cin >> N >> M;
  int i, j;
  int a, b, c;
  int** A = new int*[N];
  for (i = 0; i < N; i++) {
    A[i] = new int[N];
  }
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      if (i == j) {
        A[i][j] = 0;
      } else {
        A[i][j] = -1;
      }
    }
  }
  for (i = 0; i < M; i++) {
    cin >> a >> b >> c;
    A[a - 1][b - 1] = c;
    A[b - 1][a - 1] = c;
  }
  int aw = 0;
  for (i = 0; i < N; i++) {
    for (j = 0; j < N; j++) {
      if (A[i][j] != -1) {
        for (int k = 0; k < N; k++) {
          if (k != i && k != j) {
            if (A[i][k] != -1 && A[k][j] != -1) {
              int d = A[i][k] + A[k][j];
              if (A[i][j] > d) {
                aw++;
              }
            }
          }
        }
      }
    }
  }
  cout << aw / 2 << endl;
  for (i = 0; i < N; i++) {
    delete[] A[i];
  }
  delete[] A;
  return 0;
}
