#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int dp[200][200];
int a[1234], b[1234], c[1234];
signed main() {
	int n, m; cin >> n >> m;
	for1(i, n)for1(j, n)dp[i][j] = (i == j ? 0 : mod);
	for1(i, m) {
		cin >> a[i] >> b[i] >> c[i]; dp[a[i]][b[i]] = c[i]; dp[b[i]][a[i]] = c[i];
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	int ans = 0;
	for1(i, m) if (dp[a[i]][b[i]] < c[i])ans++;
	cout << ans << endl;
}