#include <bits/stdc++.h>

int main()
{
	int n, m, distance[100][100]{}, edge[100][100]{};
	std::fill(distance[0], distance[0] + 10000, 1000000000);
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		a--; b--;
		distance[a][b] = distance[b][a]
		= edge[a][b] = edge[b][a] = c;
	}
	for (int i = 0; i < n; i++)
		distance[i][i] = 0;

	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			for (int k = j + 1; k < n; k++)
				distance[k][j] = distance[j][k] = std::min(distance[j][k], distance[j][i] + distance[i][k]);
	
	int count{};
	for(int i = 0; i < n; i++)
		for (int j = i + 1; j < n; j++)
			if (distance[i][j] < edge[i][j])
				count++;
	printf("%d\n", count);

	return 0;
}