#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N, M, d[110][110], a[110], b[110], c[110], ans = 0;
  scanf("%lld%lld", &N, &M);
  for (int i = ((int)(1)); i <= ((int)(N)); i++) {
    for (int j = ((int)(1)); j <= ((int)(N)); j++) {
      if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = 1e12;
      }
    }
  }
  for (int i = 0; i < ((int)(M)); i++) {
    scanf("%lld%lld%lld", &a[i], &b[i], &c[i]);
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = ((int)(1)); k <= ((int)(N)); k++) {
    for (int i = ((int)(1)); i <= ((int)(N)); i++) {
      for (int j = ((int)(1)); j <= ((int)(N)); j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  for (int i = 0; i < ((int)(M)); i++) {
    if (c[i] > d[a[i]][b[i]]) ans++;
  }
  printf("%lld\n", ans);
  return 0;
}
