#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define Rep(i, n) for(int i = 1; i <= n; ++i)
typedef long long LL;

const int INF = 0x3f3f3f3f;

int d[101][101], a[1009], b[1009], c[1009];

int main()
{
	int n, m;
	cin >> n >> m;
	memset(d, 0x3f, sizeof(d));
	rep(i, m) {
		scanf("%d%d%d", a+i, b+i, c+i);
		d[a[i]][b[i]] = d[b[i]][a[i]] = c[i];
	}
	Rep(k, n) Rep(i, n) Rep(j, n) d[i][j] = min(d[i][k] + d[k][j], d[i][j]);
	int ans = 0;
	rep(i, m) if(d[a[i]][b[i]] != c[i]) ++ans;
	cout << ans << endl;
	return 0;
}