#include <bits/stdc++.h>
int g[100][100];
int main() {
  int n, m;
  std::cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j)
        g[i][j] = 0;
      else
        g[i][j] = 1 << 29;
    }
  }
  int a[100], b[100], c[100];
  for (int i = 0; i < m; i++) {
    std::cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    g[a[i]][b[i]] = c[i];
    g[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        g[i][j] = g[i][j] > g[i][k] + g[k][j] ? g[i][k] + g[k][j] : g[i][j];
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    ans += c[i] > g[a[i]][b[i]];
  }
  printf("%d\n", ans);
}
