#include <iostream>
#include <vector>
using namespace std;

class Node{
public:
	vector<int> ecost;
	bool done;
	int cost;
	vector<int> wayid
	int from;
	void init(int n){ ecost.resize(n); wayid.resize(n); }
};
void find(bool *unused, Node *node, int i, int j, int n);
int main(){
	int n, m;
	cin >> n >> m;

	int a[m], b[m], c[m];

	int i, j;
	for(i=0; i<m; i++){
		cin >> a[i] >> b[i] >> c[i];
	}
	Node node[n];
	for(i=0; i<n; i++){
		node[i].init(n);
	}
	for(i=0; i<n; i++){
		node[a[i]].ecost[b[i]] = c[i];
		node[b[i]].ecost[a[i]] = c[i];
		node[a[i]].wayid[b[i]] = i;
		node[b[i]].wayid[a[i]] = i;
	}
	bool unused[m];
	for(i=0; i<m; i++){
		unused[i]=1;
	}
//i...start, j...end
	int k;
	for(i=0; i<n; i++){
	for(j=0; j<n; j++){
		if(i>=j) continue;
		for(k=0; k<n; k++) { node.done=0; node.cost=-1; }
		find(unused, node, i, j, n);
	}
	}
	int a;
	for(i=0; i<n; i++){
		a+=unused[i];
	}
	cout << a << endl;
	return 0;
}


void find(bool *unused, Node *node, int s, int g, int n){
	int i , j, k;

	node[s].done=1;
	for(i=0; i<n; i++){
		if(node[s].ecost[i]){
			node[i].cost=node[s].ecost;
			node[i].from = s;
		}
	}
	while(1){
		for(i=0; i<n; i++){
			if(node[i].done) continue;
			if(node[i].cost <0) continue;
			k=0;
			for(j=0; j<n; j++){
				if(node[j].cost<0) { 
					node[j].cost=node[i].ecost[j];
					node[j].from=i;
					k=1;
					continue;
				}
				if(node[j].cost>node[i].ecost[j]+node[i].cost){
					node[j].cost=node[i].ecost[j]+node[i].cost;
					node[j].from=i;
					k=1;
					continue;
				}
			}
			if(k==0) node[i].done=1;
		}
		j=1;
		for(i=0; i<n; i++){
			j*=node[i].done;
		}
		if(j) break;
	}

	i=g;
	while(1){
		unused[node[i].wayid[node[i].from]] = 0;
		i=node[i].from;
		if(i==s) break;
	}
}