#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<tuple>

using namespace std;
const int INF = (int)1e9;

int main(){
	int n, m, ans = 0;
	cin >> n >> m;
	vector<vector<int>> d(n + 1, vector<int>(n + 1, INF));
	vector<tuple<int, int, int>> e(m);
	for(int i = 0; i <= n; i++){
		d[i][i] = 0;
	}
	for(int i = 0; i < m; i++){
		int a, b, c;
		cin >> a >> b >> c;
		e[i] = tie(a, b, c);
		d[a][b] = c;
		d[b][a] = c;
	}
	for(int k = 1; k <= n; k++){
		for(int i = 1; i <= n; i++){
			for(int j = 1; j <= n; j++){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	for(int i = 0; i < m; i++){
		int a, b, c;
		tie(a, b, c) = e[i];
		if(d[a][b] != c) ans++;
	}
	cout << ans << endl;
	return 0;
}
