#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 29;
int main() {
  int n, m, a[100], b[100], c[100];
  scanf("%d%d", &n, &m);
  for (int i = 0; i < (m); i++)
    scanf("%d%d%d", &a[i], &b[i], &c[i]), a[i]--, b[i]--;
  int d[100][100];
  for (int u = 0; u < (n); u++)
    for (int v = 0; v < (n); v++) d[u][v] = d[v][u] = (u == v ? 0 : INF);
  for (int i = 0; i < (m); i++) d[a[i]][b[i]] = d[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++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  int ans = 0;
  for (int i = 0; i < (m); i++)
    if (c[i] > d[a[i]][b[i]]) ans++;
  printf("%d\n", ans);
  return 0;
}
