#include <iostream>
#include <cstring>
#include <string>
using namespace std;

int inf = 1e9+7;
int path[107][107],ind[107][107];
int main(){
	int n,m;
	int u,v,w;
	
	cin >> n >> m;
	
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=n;j++){
			path[i][j] = inf;
			ind[i][j] = inf;
		}
	}
	while(m--){
		cin >> u >> v >> w;
		path[u][v] = w;
		path[v][u] = w;
		ind[u][v] = w;
		ind[v][u] = w;
	}
	
	for(int i = 1;i<=n;i++){
		for(int j = 1;j<=n;j++){
			for(int k = 1;k<=n;k++){
				path[j][k] = min(path[j][k],path[j][i]+path[i][k]);
			}
		}
	}
	int ans = 0;
	for(int i = 1;i<=n;i++){
		for(int j = i+1;j<=n;j++){
			if(ind[i][j]!=inf&&ind[i][j]>path[i][j]) ans++;
		}
	}
	cout << ans;
}