#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int n, m;
int main() {
  cin >> n >> m;
  vector<vector<int>> e(n, vector<int>(n, 1e6));
  vector<vector<int>> inv(n, vector<int>(n, 1e6));
  vector<int> a(m);
  vector<int> b(m);
  vector<int> c(m);
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    --a[i];
    --b[i];
    e[a[i]][b[i]] = c[i];
    e[b[i]][a[i]] = c[i];
    inv[a[i]][b[i]] = i;
    inv[b[i]][a[i]] = i;
  }
  for (long long i = 0; i < (long long)(n); i++) {
    e[i][i] = 0;
  }
  vector<vector<int>> next(n, vector<int>(n, 0));
  for (long long i = 0; i < (long long)(n); i++) {
    for (long long j = 0; j < (long long)(n); j++) {
      next[i][j] = j;
    }
  }
  for (long long k = 0; k < (long long)(n); k++) {
    for (long long i = 0; i < (long long)(n); i++) {
      for (long long j = 0; j < (long long)(n); j++) {
        if (chmin(e[i][j], e[i][k] + e[k][j])) {
          next[i][j] = next[i][k];
        }
      }
    }
  }
  vector<bool> used(m, false);
  for (long long i = 0; i < (long long)(n); i++) {
    for (long long j = 0; j < (long long)(n); j++) {
      if (i != j) {
        int prov = i;
        int cur = next[prov][j];
        for (; cur != j; cur = next[cur][j]) {
          used[inv[prov][cur]] = true;
          prov = cur;
        }
      }
    }
  }
  int res = 0;
  for (long long i = 0; i < (long long)(m); i++) {
    if (!used[i]) {
      res++;
    }
  }
  cout << res << "\n";
  return 0;
}
