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