#include <bits/stdc++.h>
const int MOD = 1e9 + 7;
const int INF = 1e9;
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int a[N + 1], b[N + 1], c[N + 1];
  int d[N + 1][N + 1];
  for (int i = 1, i_len = (N + 1); i < i_len; ++i)
    for (int j = 1, j_len = (N + 1); j < j_len; ++j) d[i][j] = INF;
  for (int i = 0, i_len = (M); i < i_len; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    d[a[i]][b[i]] = c[i];
    d[b[i]][a[i]] = c[i];
  }
  for (int k = 1, k_len = (N + 1); k < k_len; ++k)
    for (int i = 1, i_len = (N + 1); i < i_len; ++i)
      for (int j = 1, j_len = (N + 1); j < j_len; ++j)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  long long int ans = M;
  for (int p = 0, p_len = (M); p < p_len; ++p) {
    bool hasPath = false;
    for (int s = 1, s_len = (N + 1); s < s_len; ++s) {
      if (d[s][a[p]] + c[p] == d[s][b[p]]) {
        hasPath = true;
      }
    }
    if (hasPath) {
      ans--;
    }
  }
  cout << ans << endl;
}
