#include <bits/stdc++.h>
using namespace std;
int n, m, ans, a[1005], b[1005], c[1005], d[105][105];
int main() {
  int i, j, k;
  cin >> n >> m;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (i != j) d[i][j] = 1e9;
  for (i = 0; i < m; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
    d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
    d[b[i]][a[i]] = min(d[b[i]][a[i]], c[i]);
  }
  for (k = 1; i <= n; i++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  for (i = 0; i < m; i++)
    if (d[a[i]][b[i]] < c[i]) ans++;
  cout << ans << endl;
  return 0;
}
