#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long INF = 1e18;
int main() {
  int n, m;
  cin >> n >> m;
  long long dis[110][110], dist[110][110];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (i == j) {
        dis[i][j] = 0;
      } else {
        dis[i][j] = INF;
      }
    }
  }
  int a[m + 1], b[m + 1], c[m + 1];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    dis[a[i]][b[i]] = c[i];
    dis[b[i]][a[i]] = c[i];
  }
  long long ans = 0;
  if (n - 1 == m) {
    cout << 0 << endl;
  } else {
    for (int k = 0; k < n; k++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
          dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
        }
      }
    }
    for (int i = 0; i < m; i++) {
      if (dis[a[i]][b[i]] != c[i]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
