#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int g[101][101];
int es[101][101];
int main() {
	int N, M; cin >> N >> M;
	rep(i, N) rep(j, N) g[i][j] = 1 << 29;
	rep(i, M) {
		int a, b, c; cin >> a >> b >> c;
		a--; b--;
		es[a][b] = es[b][a] = g[a][b] = g[b][a] = c;
	}
	rep(k, N) rep(i, N) rep(j, N) g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
	rep(i, N) rep(j, i + 1, N) if (es[i][j] == g[i][j]) M--;
	cout << M << endl;
}