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

const int inf = 1e9;
int g[100][100];
int gg[100][100];

int main() {
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			g[i][j] = inf;
		}
		g[i][i] = 0;
	}
	for (int i = 0; i < m; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--; v--;
		gg[u][v] = g[u][v] = min(g[u][v], w);
		gg[v][u] = g[v][u] = min(g[v][u], w);
	}
	for (int k = 0; k < n; k++) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
			}
		}
	}

	int ans = m;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (gg[i][j] != inf && g[i][j] == gg[i][j]) {
				ans--;
			}
		}
	}
	cout << ans << endl;
}