#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(void){
	int N,M;
	cin >> N >> M;
	vector<vector<ll>> g(N,vector<ll>(N,1e9+7));
	vector<ll> a(M),b(M),c(M);
	for(int i=0;i<M;i++){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;b[i]--;
		g[a[i]][b[i]] = min(g[a[i]][b[i]],c[i]);
		g[b[i]][a[i]] = min(g[b[i]][a[i]],c[i]);
	}
	rep(k,N)rep(i,N)rep(j,N)g[i][j] = min(g[i][j],g[i][k]+g[k][j]);
	ll ans = 0;
	for(int i=0;i<M;i++){
		if(c[i] != g[a[i]][b[i]])ans++;
	}
	cout << ans << endl;
}