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