#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define inf 1000000009
int graf[105][105];
int a[1001], b[1001], c[1001];

int main() {
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)if(i!=j)graf[i][j] = inf;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		graf[a[i] - 1][b[i] - 1] = c[i];
		graf[b[i] - 1][a[i] - 1] = c[i];
	}

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = 0; k < n; k++)graf[j][k] = min(graf[j][k], graf[j][i] + graf[i][k]);

	int ans = m;
	for (int i = 0; i < m; i++) {
		int f = 0;
		for (int j = 0; j < n; j++) {
			if (graf[j][a[i] - 1] + c[i] == graf[j][b[i] - 1]) {
				f++;
			}
		}
		if (f)ans--;
	}
	cout << ans << endl;
}