#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[101][101],n,m;
int A[101],B[101],C[101];
main(){
	r(i,101)r(j,101)a[i][j]=(i==j?0:1e8);
	cin>>n>>m;
	r(i,m){
		cin>>A[i]>>B[i]>>C[i];
		A[i]--;B[i]--;
		a[A[i]][B[i]]=a[B[i]][A[i]]=C[i];
	}
	r(o,n)r(i,n)r(j,n)a[i][j]=min(a[i][j],a[i][o]+a[o][j]);
	int sum=0;
	r(i,m){
		int X=1;
		r(j,n){
			r(k,n){
				if(a[j][k]==a[j][A[i]]+C[i]+a[B[i]][k])X=0;
			}
		}
		sum+=X;
	}
	cout<<sum<<endl;
}