#include <bits/stdc++.h>
using namespace std;
long long weight[2000][2000];
long long dp[2000][2000];
vector<pair<long long, long long> > edges;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= 1000; i++) {
    for (long long j = 1; j <= 1000; j++) weight[i][j] = dp[i][j] = 1e12;
  }
  for (long long i = 0; i < m; i++) {
    long long u, v, w;
    cin >> u >> v >> w;
    if (v < u) swap(u, v);
    edges.push_back(make_pair(u, v));
    dp[u][v] = w;
    weight[u][v] = w;
  }
  for (long long k = 1; k <= n; k++) {
    for (long long i = 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
      }
    }
  }
  for (long long i = 1; i <= n; i++) dp[i][i] = 0, weight[i][i] = 0;
  long long res = 0;
  for (auto z : edges) {
    long long u = z.first;
    long long v = z.second;
    bool okay = false;
    for (long long i = 1; i <= n; i++) {
      for (long long j = i + 1; j <= n; j++) {
        if (i == u && j == v) continue;
        if (dp[i][j] == dp[i][u] + weight[u][v] + dp[v][j]) {
          okay = true;
        }
      }
      if (okay) break;
    }
    if (!okay) {
      res++;
    }
  }
  cout << res / 2 << '\n';
  return 0;
}
