#include <bits/stdc++.h>
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  int f[m];
  int wf[n + 1][n + 1];
  int len[n + 1][n + 1];
  int dir[n + 1][n + 1][m + 1];
  for (int i = 0; i < n + 1; i++) {
    for (int j = 0; j < n + 1; j++) {
      len[i][j] = 0;
      wf[i][j] = 1000000;
      if (i == j) {
        wf[i][j] = 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][len[a][b]++] = i;
    dir[b][a][len[b][a]++] = i;
  }
  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];
          int x = 0;
          for (int l = 0; l < len[i][k]; l++) {
            int sf = 1;
            for (int p = 0; p < x; p++) {
              if (dir[i][k][l] == dir[i][j][p]) {
                sf = 0;
                break;
              }
            }
            if (sf) {
              dir[i][j][x++] = dir[i][k][l];
            }
          }
          for (int l = 0; l < len[k][j]; l++) {
            int sf = 1;
            for (int p = 0; p < x; p++) {
              if (dir[k][j][l] == dir[i][j][p]) {
                sf = 0;
                break;
              }
            }
            if (sf) {
              dir[i][j][x++] = dir[i][k][l];
            }
          }
          len[i][j] = x;
        }
      }
    }
  }
  for (int i = 1; i < n + 1; i++) {
    for (int j = 1; j < n + 1; j++) {
      for (int k = 0; k < len[i][j]; k++) {
        f[dir[i][j][k]] = 0;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    if (f[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}
