#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, M;
  cin >> N >> M;
  vector<vector<long long>> d(N + 1, vector<long long>(N + 1, 1e18));
  vector<pair<long long, long long>> edge(M);
  vector<long long> cost(M);
  for (long long i = (0); i < (long long)(M); i++) {
    long long a, b, c;
    cin >> a >> b >> c;
    d[a][b] = c;
    d[b][a] = c;
    edge[i] = {a, b};
    cost[i] = c;
  }
  for (long long i = (1); i < (long long)(N + 1); i++) d[i][i] = 0;
  for (long long i = (1); i < (long long)(N + 1); i++) {
    for (long long j = (1); j < (long long)(N + 1); j++) {
      for (long long k = (1); k < (long long)(N + 1); k++) {
        d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
      }
    }
  }
  vector<bool> v(M, false);
  for (long long i = (1); i < (long long)(N); i++) {
    for (long long j = (i + 1); j < (long long)(N + 1); j++) {
      for (long long k = (0); k < (long long)(M); k++) {
        long long a = edge[k].first;
        long long b = edge[k].second;
        if (d[i][b] + cost[i] + d[a][j] == d[i][j]) v[k] = true;
        if (d[i][a] + cost[i] + d[b][j] == d[i][j]) v[k] = true;
      }
    }
  }
  long long ans = 0;
  for (long long i = (0); i < (long long)(M); i++) {
    if (!v[i]) {
      cerr << i << endl;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
