#include <bits/stdc++.h>

using namespace std;

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> e(n, vector<int>(n, 1e9));
	vector<vector<int>> d(n, vector<int>(n, -1));
	for (int i = 0; i < n; i++) {
		e[i][i] = 0;
	}
	for (int i = 0; i < m; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		d[u][v] = d[v][u] = e[u][v] = e[v][u] = w;
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				e[i][j] = min(e[i][j], e[i][k] + e[k][j]);
			}
		}
	}
	int res = m;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (d[i][j] == e[i][j]) {
				res--;
			}
		}
	}
	cout << res << '\n';

	return 0;
}

