#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll d[123][123];

int main(void){
	int n,m,a[1111],b[1111],i,j,k,ans=0;
	ll c[1111];
	cin >> n >> m;
	fill(d[0],d[123],INFLL);
	for(i=0; i<m; ++i){
		cin >> a[i] >> b[i] >> c[i];
		--a[i]; --b[i];
		d[a[i]][b[i]] = c[i];
		d[b[i]][a[i]] = c[i];
	}
	for(k=0; k<n; ++k){
		for(i=0; i<n; ++i){
			for(j=0; j<n; ++j){
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	for(i=0; i<m; ++i){
		if(d[a[i]][b[i]]<c[i]){
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}
