#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int f[m];
  long long int wf[n + 1][n + 1];
  int dir[n + 1][n + 1][m];
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      wf[i][j] = 1000000000;
      if (i == j) {
        wf[i][j] = 0;
      }
      for (int k = 0; k < m; k++) {
        dir[i][j][k] = 0;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    f[m] = 1;
    wf[a][b] = c;
    wf[b][a] = c;
    dir[a][b][i] = 1;
    dir[b][a][i] = 1;
  }
  for (int k = 1; k < n + 1; k++) {
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < n + 1; j++) {
        if (wf[i][j] > wf[i][k] + wf[k][j]) {
          wf[i][j] = wf[i][k] + wf[k][j];
          for (int l = 0; l < m; l++) {
            if (dir[i][k][l] || dir[k][j][l]) {
              dir[i][j][l] = 1;
            } else {
              dir[i][j][l] = 0;
            }
          }
        }
      }
    }
  }
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      for (int k = 0; k < m; k++) {
        if (dir[i][j][k]) {
          f[k] = 0;
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (f[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
