#include <bits/stdc++.h>
using namespace std;
int d[110][110];
int main() {
  int n, m;
  int a[1010], b[1010], c[1010];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  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] = INT_MAX;
    }
  }
  for (int i = 0; i < m; i++) {
    d[a[i]][b[i]] = min(d[a[i]][b[i]], c[i]);
    d[b[i]][a[i]] = min(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 ans = m;
  for (int i = 0; i < m; i++) {
    bool check = false;
    for (int j = 0; j < n; j++) {
      if (d[j][a[i]] + c[i] == d[j][b[i]]) check = true;
    }
    if (check) ans--;
  }
  cout << ans << endl;
  return 0;
}
