#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, m;
	cin >> n >> m;
	
	vector< vector< int > > dst(n, vector< int >(n, 1 << 29));
	for_(i,0,n) dst[i][i] = 0;
	
	struct Edge { int u, v, c; };
	vector< Edge > edges;
	for_(i,0,m) {
		int u, v, c;
		cin >> u >> v >> c;
		--u; --v;
		edges.push_back(Edge{u, v, c});
		dst[u][v] = dst[v][u] = c;
	}
	
	for_(k,0,n) for_(i,0,n) for_(j,0,n) dst[i][j] = min(dst[i][j], dst[i][k] + dst[k][j]);
	
	int ans = 0;
	for (Edge e : edges) if (dst[e.u][e.v] < e.c) ++ans;
	cout << ans << endl;
}