#include <bits/stdc++.h>
using namespace std;
const int OO = int(1e9);
int a[200], b[200], c[200];
int d[200][200];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (n); ++j) d[i][j] = (i == j ? 0 : OO);
  for (int i = (0); i < (m); ++i) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    d[a[i]][b[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 ans = 0;
  for (int t = (0); t < (m); ++t) {
    bool need = false;
    int u = a[t], v = b[t];
    for (int i = (0); i < (n); ++i)
      for (int j = (0); j < (n); ++j)
        if (d[i][j] == d[i][u] + 1 + d[v][j] ||
            d[i][j] == d[i][v] + 1 + d[u][j])
          need = true;
    ans += (!need);
  }
  cout << ans << '\n';
}
