#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int inf = 100000000;
  int dis[n][n];
  int a[n], b[n];
  int x[n];
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> x[i];
    a[i]--;
    b[i]--;
  }
  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;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    dis[a[i]][b[i]] = min(dis[a[i]][b[i]], x[i]);
    dis[b[i]][a[i]] = min(dis[b[i]][a[i]], x[i]);
  }
  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]);
      }
    }
  }
  int ans = m;
  for (int i = 0; i < m; i++) {
    bool sht = false;
    for (int j = 0; j < n; j++)
      if (dis[j][a[i]] + x[i] == dis[j][b[i]]) sht = true;
    if (sht == true) {
      ans -= 1;
    }
  }
  cout << ans << endl;
}
