#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int d[n][n];
  int a[m], b[m], c[m];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) d[i][j] = (i == j ? 0 : INT_MAX);
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int cnt = 0;
  for (int t = 0; t < m; t++) {
    bool flag = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (d[i][j] == d[i][a[t]] + c[t] + d[b[t]][j]) flag = 1;
      }
    }
    if (!flag) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
