#include <iostream>
#define inf 1000000000

using namespace std;

int N, M;
int G[105][105];
int dist[105][105];

int main(void)
{
	cin >> N >> M;
	int a, b, c;
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			G[i][j] = inf;
		}
	}
	for(int i = 0; i < M; i++){
		cin >> a >> b >> c;
		G[a][b] = G[b][a] = c;
	}
	
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			dist[i][j] = G[i][j];
		}
	}
	for(int k = 1; k <= N; k++){
		for(int i = 1; i <= N; i++){
			for(int j = 1; j <= N; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			if(G[i][j] >= inf) continue;
			if(G[i][j] > dist[i][j]) ans++;
		}
	}
	
	cout << ans/2 << endl;
	return 0;
}