#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define INF (1<<29)

int n, m;
int mincost[100][100];
int a[1000], b[1000], c[1000];

int main() {
	cin >> n >> m;
	
	fill(mincost[0], mincost[n], INF);
	
	REP(i, n) mincost[i][i] = 0;
	REP(i, m) {
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		a[i]--; b[i]--;
		mincost[a[i]][b[i]] = mincost[b[i]][a[i]] = c[i];
	}
	REP(k, n) REP(i, n) REP(j, n) {
		mincost[i][j] = min(mincost[i][j], mincost[i][k] + mincost[k][j]);
	}
	
	int ans = 0;
	REP(i, m) {
		if (mincost[a[i]][b[i]] < c[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}