#include <bits/stdc++.h>
using namespace std;
int n, m;
int d[101][101];
int a[101], b[101], c[101];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (int i = 0; i < 101; i++)
    for (int j = 0; j < 101; j++) d[i][j] = (i == j ? 0 : 900000000);
  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 < 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 srt = false;
    for (int j = 0; j < n; j++)
      if (d[j][a[i]] + c[i] == d[b[i]][j]) srt = true;
    if (srt) ans--;
  }
  cout << ans << endl;
  return 0;
}
