#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int V, E;
  cin >> V >> E;
  vector<int> a(E), b(E), c(E);
  for (int i = 0; i < E; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
  }
  vector<vector<int> > d(V, vector<int>(V, INT_MAX / 2));
  for (int v = 0; v < V; v++) {
    d[v][v] = 0;
  }
  for (int i = 0; i < E; i++) {
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int i = 0; i < V; i++) {
    for (int j = 0; j < V; j++) {
      for (int k = 0; k < V; k++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  int ans = E;
  for (int e = 0; e < E; e++) {
    bool shortest = false;
    for (int i = 0; i < V; i++) {
      if (d[i][a[e]] + c[e] == d[i][b[e]]) shortest = true;
    }
    if (shortest == true) {
      ans--;
    }
  }
  cout << ans << "\n";
  return 0;
}
