#include <bits/stdc++.h>
int main() {
  int N, M;
  int a, b, c, d[100][100] = {}, e[100][100] = {};
  int i, j, k;
  int z, count;
  int min;
  scanf("%d %d", &N, &M);
  for (i = 0; i < M; i++) {
    scanf("%d %d %d", &a, &b, &c);
    d[a][b] = c;
    d[b][a] = c;
  }
  for (i = 1; i <= N; i++) {
    for (j = 1; j < i; j++) {
      z = 0;
      for (k = 1; k <= N; k++) {
        if (d[i][j] != 0) {
          min = d[i][j];
        } else {
          min = d[j][i];
        }
        e[i][j] = 1;
        e[j][i] = 1;
        if (d[i][k] + d[k][j] < min && i != j) {
          min = d[i][k] + d[k][j];
          e[i][k] = 1;
          e[k][i] = 1;
          e[k][j] = 1;
          e[j][k] = 1;
          if (z != 0) {
            e[i][z] = 0;
            e[z][i] = 0;
            e[z][j] = 0;
            e[j][z] = 0;
          } else {
            e[i][j] = 0;
            e[j][i] = 0;
          }
          z = k;
        }
      }
    }
    for (j = i + 1; j <= N; j++) {
      z = 0;
      for (k = 1; k <= N; k++) {
        if (d[i][j] != 0) {
          min = d[i][j];
        } else {
          min = d[j][i];
        }
        e[i][j] = 1;
        e[j][i] = 1;
        if (d[i][k] + d[k][j] < min && i != j) {
          min = d[i][k] + d[k][j];
          e[i][k] = 1;
          e[k][i] = 1;
          e[k][j] = 1;
          e[j][k] = 1;
          if (z != 0) {
            e[i][z] = 0;
            e[z][i] = 0;
            e[z][j] = 0;
            e[j][z] = 0;
          } else {
            e[i][j] = 0;
            e[j][i] = 0;
          }
          z = k;
        }
      }
    }
  }
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      if (e[i][j] == 1) {
        count++;
      }
    }
  }
  printf("%d\n", M - (count / 2));
  return 0;
}
