#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int A[101][101] = {};
  for (int i = 1; i <= (100); i++) {
    for (int ii = 1; ii <= (100); ii++) {
      if (i != ii) A[i][ii] = 10000;
    }
  }
  for (int i = 0; i < (M); i++) {
    int a, b, c;
    cin >> a >> b >> c;
    A[a][b] = c;
    A[b][a] = c;
  }
  int B[101][101] = {};
  for (int k = 1; k <= (100); k++) {
    for (int i = 1; i <= (100); i++) {
      for (int j = 1; j <= (100); j++) {
        if (A[i][k] + A[k][j] < A[i][j]) {
          B[i][j] = 1;
          A[i][j] = A[i][k] + A[k][j];
        }
      }
    }
  }
  int goukei = 0;
  for (int i = 1; i <= (100); i++) {
    for (int ii = 1; ii <= (100); ii++) {
      if (B[i][ii]) goukei++;
    }
  }
  int hennmax = N * (N - 1) / 2;
  cout << (goukei / 2 + M - hennmax) << "\n";
  return 0;
}
