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

int main()
{
	int N, M;
	cin >> N >> M;
	vector<int> a(M), b(M), c(M);
	vector<vector<int>> dp(N, vector<int>(N, 100000000));
	for (int i = 0; i < N; i++) {
		dp[i][i] = 0;
	}
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i] >> c[i];
		dp[a[i] - 1][b[i] - 1] = dp[b[i] - 1][a[i] - 1] = c[i];
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	int res = 0;
	for (int i = 0; i < M; i++) {
		if (dp[a[i] - 1][b[i] - 1] < c[i]) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}
