#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
const long long N = 1e2 + 10;
const long long mod = 1e9 + 7;
long long gr[N][N];
bool vis[N][N];
long long n, a, b, w, m;
pair<long long, long long> edge[N * 10];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= n; ++j) {
      gr[i][j] = 1e18;
    }
    gr[i][i] = 0;
  }
  for (long long i = 0; i < m; ++i) {
    cin >> a >> b >> w;
    gr[a][b] = w;
    gr[b][a] = w;
    edge[i] = {a, b};
  }
  map<pair<long long, long long>, long long> mp;
  for (long long k = 1; k <= n; ++k) {
    for (long long i = 1; i <= n; ++i) {
      pair<long long, long long> p = {0, 0};
      for (long long j = 1; j <= n; ++j) {
        long long dis = gr[i][k] + gr[k][j];
        if (dis < gr[i][j]) {
          p = {k, j};
          gr[i][j] = dis;
        }
      }
      mp[p]++;
      mp[{p.second, p.first}]++;
    }
  }
  long long ans = m;
  for (long long i = 0; i < m; ++i) {
    if (mp[edge[i]]) ans--;
  }
  cout << ans;
  return 0;
}
