#include <bits/stdc++.h>
using namespace std;
int n, m, u, v, w, s, a[105][105], b[105][105];
int main() {
  int i, j, k;
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++) a[i][j] = 1e9;
  while (m--) {
    cin >> u >> v >> w;
    a[u][v] = a[v][u] = b[u][v] = b[v][u] = w;
  }
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
  for (i = 1; i <= n; i++)
    for (j = i + 1; j <= n; j++) s += a[i][j] < b[i][j];
  cout << s;
  return 0;
}
