#include <bits/stdc++.h>
int main() {
  int n, m, a[1002], b[1002], c[1002], root[102][102];
  memset(root, (int)1e9, sizeof(root));
  for (int i = 0; i < 102; i++) root[i][i] = 0;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    root[a[i]][b[i]] = c[i];
    root[b[i]][a[i]] = c[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++)
        root[i][j] = ((root[i][j]) < (root[i][k] + root[k][j])
                          ? (root[i][j])
                          : (root[i][k] + root[k][j]));
  int ans = m;
  for (int k = 0; k < m; k++) {
    for (int i = 1; i < n + 1; i++) {
      for (int j = 1; j < n + 1; j++) {
        if (root[i][j] == root[i][a[k]] + c[k] + root[b[k]][j] ||
            root[i][j] == root[j][a[k]] + c[k] + root[b[k]][i]) {
          ans--;
          goto NEXT;
        }
      }
    }
  NEXT:;
  }
  printf("%d\n", ans);
}
