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

int main() {
	int N, M, a, b, c, INF = 1000000000, ans = 0;
	static int R[100][100] = {}, F[100][100] = {};
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			R[i][j] = F[i][j] = INF;
			if (i == j) R[i][j] = F[i][j] = F[j][i] = 0;
		}
	}
	for (int i = 0; i < M; i++) {
		cin >> a >> b >> c;
		a--, b--;
		R[a][b] = F[a][b] = F[b][a] = c;
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				F[i][j] = min(F[i][j], F[i][k] + F[k][j]);
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (R[i][j] != INF) {
				if (R[i][j] != F[i][j]) ans++;
			}
		}
	}
	cout << ans;
}