#include <bits/stdc++.h>
#define int long long
#define endre getchar();getchar();return 0
#define INF 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

int n,m,ans;
int co[105][105];
int from[21005],to[21005],cost[21005];
signed main() {
	cin>>n>>m;
	rep(i,n)rep(j,n)co[i][j]=INF;
	rep(i,m){
		cin>>from[i]>>to[i]>>cost[i];
		co[from[i]-1][to[i]-1]=cost[i];
		co[to[i]-1][from[i]-1]=cost[i];
	}
	rep(k,n)rep(i,n)rep(j,n)co[i][j]=min(co[i][j],co[i][k]+co[k][j]);
	rep(i,m){
		if(co[from[i]-1][to[i]-1]!=cost[i])ans++;
	}
	cout<<ans<<endl;
}

