#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX
#define eps LDBL_EPSILON
#define moder 100000
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
struct edge{int from,to,cost;};
int n,m,a,b,c;
int d[110][110];
vector<edge> vec;
signed main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)d[i][j]=INF;
	}
	rep(i,m){
		cin>>a>>b>>c;
		d[a][b]=min(d[a][b],c);
		d[b][a]=min(d[b][a],c);
		vec.push_back({a,b,c});
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	int ans=0;
	for(edge e:vec){
		if(d[e.from][e.to]<e.cost)ans++;
	}
	cout<<ans<<endl;
	return 0;
}