#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll dis[110][110];
ll a[1010], b[1010], c[1010];
int main() {
	ll n, m, inf = 1e15;
	for (int i = 0; i<110; i++)for (int j = i + 1; j < 110; j++)dis[i][j] = dis[j][i] = inf;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		dis[a[i]][b[i]] = dis[b[i]][a[i]] = c[i];
	}
	for (int k = 0; k<n; k++)for (int i = 0; i<n; i++)for (int j = 0; j<n; j++)dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
	ll ans = m;
	for (int i = 0; i<m; i++)for (int j = 0; j<n; j++) {
		if (dis[j][a[i]] + c[i] == dis[j][b[i]]) {
			ans--;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}