#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

const int INF=1e8;
const int MAX_N=100,MAX_M=1000;

int N,M;
int A[MAX_M],B[MAX_M],C[MAX_M];

int G[MAX_N][MAX_N];

void warshall_floyd(){
	REP(k,N){
		REP(i,N){
			REP(j,N){
				G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
			}
		}
	}
}

int main(){
	cin>>N>>M;
	REP(i,N){
		REP(j,N){
			if (i==j){
				G[i][j]=0;
			}else{
				G[i][j]=INF;
			}
		}
	}
	REP(i,M){
		cin>>A[i]>>B[i]>>C[i];
		A[i]--;
		B[i]--;
		G[A[i]][B[i]]=C[i];
		G[B[i]][A[i]]=C[i];
	}
	warshall_floyd();
	int ans=0;
	REP(i,M){
		int a=A[i],b=B[i],c=C[i];
		REP(j,N){
			REP(k,N){
				if (G[j][k]==G[j][a]+G[b][k]+c){
					ans++;
					j=k=N;
				}
			}
		}
	}
	ans=M-ans;
	cout<<ans<<endl;
	return 0;
}
