#include<cstdio>
#include<algorithm>

using namespace std;

#define INF 1 << 29
#define rep(i, n) for(int i = 0; i < n; i++)

struct edge{
	int from, to, cost;
};

int main(){
	int n, m; scanf("%d %d", &n, &m);
	int d[100][100]; edge e[1000];
	fill(d[0], d[100], INF);
	rep(i, n) d[i][i] = 0;
	rep(i, m){
		int a, b, c; scanf("%d %d %d", &a, &b, &c);
		a--; b--; d[a][b] = d[b][a] = c; e[i] = (edge){a, b, c};
	}
	rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	int res = 0;
	rep(i, m){
		int t = 1;
		rep(j, n) if(d[j][e[i].from] + e[i].cost == d[j][e[i].to]) t = 0;
		if(t) res++;
	}
	printf("%d\n", res);
	return 0;
}