#include <iostream>
#include <tuple>
#include <queue>
#include <algorithm>
using namespace std;
typedef tuple<int, int, int> tiii;
const int INF = 1 << 29;
int N, M;
int A[101][101];
int a, b, c;
queue<tiii> q;
int main(void) {
	cin >> N >> M;
	fill_n(A[0], 101 * 101, INF);
	for (int i = 0; i < M; ++i) {
		cin >> a >> b >> c;
		--a; --b;
		A[a][b] = A[b][a] = c;
		q.push(tiii(a, b, c));
	}
	for (int k = 0; k < N; ++k) for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
		A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
	}
	int ans = M;
	while (!q.empty()) {
		tie(a, b, c) = q.front(); q.pop();
		if (A[a][b] == c) --ans;
	}
	cout << ans << endl;
	return 0;
}