#include <iostream>
#include <algorithm>
using namespace std;

#define INF 1e9

int main(){
	int n, m;
	cin >> n >> m;
	int dist[n][n];
	fill(dist[0], dist[n], INF);
	for(int i = 0; i < n; i++) dist[i][i] = 0;
	while(m--){
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		dist[a][b] = dist[b][a] = c;
	}
	int score[n][n];
	for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) score[i][j] = dist[i][j];
	for(int k = 0; k < n; k++) for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) score[i][j] = min(score[i][j], score[i][k] + score[k][j]);
	int ans = 0;
	for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) if(dist[i][j] != INF && dist[i][j] > score[i][j]) ans++;
	cout << ans << endl;
}