#include <bits/stdc++.h>
using namespace std;
int main() {
  int ans = 0;
  int n, m;
  cin >> n >> m;
  int a[m], b[m], c[m];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int d[n][n];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        d[i][j] = 0;
      } else {
        d[i][j] = 10000;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (d[i][j] > d[i][k] + d[k][j]) {
          d[i][j] = d[i][k] + d[k][j];
          ans++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
