#include <bits/stdc++.h>
#define l_ength size
using ll = long long;
using namespace std;
const int inf = 1000000;

struct edge{
	int from;
	int to;
	int cost;
};

int main(){
	int n, m; cin >> n >> m;
	int dist[n][n];
	vector<edge> graph;
	for( int i = 0; i < n; ++i ){
		for( int j = 0; j < n; ++j ){
			dist[i][j] = INF;
		}
	}
	for( int i = 0; i < n; ++i ) dist[i][i] = 0;
	for( int i = 0; i < m; ++i ){
		int a, b, c; cin >> a >> b >> c; --a; --b;
		dist[a][b] = dist[b][a] = c;
		graph.push_back( ( edge ){ a, b, c } );
	}
	for( int k = 0; k < n; ++k ){
		for( int i = 0; i < n; ++i ){
			for( int j = 0; j < n; ++j ){
				dist[i][j] = min( dist[i][j], dist[i][k]+dist[k][j] );
			}
		}
	}
	int ans = 0;
	for( auto e : graph ){
		bool flag = false;
		for( int i = 0; i < n; ++i ){
			for( int j = i+1; j < n; ++j ){
				// この条件は「i → j の最短距離に辺 e が使われる」と同値
				if( dist[i][e.from]+e.cost+dist[e.to][j] == dist[i][j] ){
					flag = true;
					goto endloop;
				}
			}
		}
		endloop:
		if( !flag ) ++ans;
	}
	cout << ans << endl;
	return 0;
}