#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,m;
	cin>>n>>m;
	vector<ll> a(m),b(m),c(m);
	FOR(i,0,m)cin>>a[i]>>b[i]>>c[i];
	ll d[n][n];
	FOR(i,0,n)FOR(j,0,n)d[i][j]=INF;
	FOR(i,0,n)d[i][i]=0;
	FOR(i,0,m){
		a[i]--;
		b[i]--;
		d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
	}
	FOR(k,0,n)
		FOR(i,0,n)
			FOR(j,0,n)
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
	ll ans = 0;
	FOR(i,0,m){
		bool ok = false;
		FOR(k,0,n)FOR(j,0,n){
			if((d[k][a[i]]+c[i]+d[b[i]][j])==d[j][k])ok=true;
		}
		if(not ok)ans++;
	}
	cout << ans << endl;
}