#include <bits/stdc++.h>
using namespace std;
const int INF = 114514810;
int main() {
  int n, m;
  cin >> n >> m;
  static int d[111][111];
  for (int(i) = (0); i < (int)(111); i++)
    for (int(j) = (0); j < (int)(111); j++) d[i][j] = INF;
  int a[111], b[111], c[111];
  for (int(i) = (0); i < (int)(m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
  }
  for (int(k) = (0); k < (int)(n); k++)
    for (int(i) = (0); i < (int)(n); i++)
      for (int(j) = (0); j < (int)(n); j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
  int cnt = 0;
  for (int(i) = (0); i < (int)(m); i++) {
    if (d[a[i]][b[i]] != c[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
