#include<bits/stdc++.h>
#define x first
#define y second
#define ll long long
#define pii pair<int, int>
#define maxn 1005
#define INF 0x7FFFFFFF
#define dbg(n) cout << n << endl
#define mod 1000000007
using namespace std;

inline void read(int &x){
	int f = 1; x = 0; char s = getchar();
    while(s > '9' || s < '0'){
		if(s == '-') f = -1;
		s = getchar();
	}
    while(s <= '9' && s >= '0'){
		x = x * 10 + s - '0';
		s = getchar();
	}
    x = x * f;
}

struct E{
	int f, t, c;
	E(int f, int t, int c) : f(f), t(t), c(c){
	};
};

int G[1005];
vector<int> GG[1005];

int main(){
	int n, m, f, t, c;
	read(n), read(m);
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= n; ++j)
			G[i][j] = INF;
	for(int i = 0; i < m; ++i){
		read(f); read(t); read(c);
		G[f][t] = c;
		GG[f].push_back(E(f, t, c));
	}
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j <= n; ++j)
			for(int k = 0; k <= n; ++k)
				G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
	int ans = 0;
	for(int i = 0; i <= n; ++i)
		for(int j = 0; j < GG[i].size(); ++j)
			if(GG[i][j].c > G[i][GG[i][j].t]) ans++;
	cout << ans << endl;
		
	
	return 0;
}
