#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define EPS (1e-10)
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int d[100][100];
struct st {
	int a, b, c;
};
vector<st>v;
int main() {
	int n, m; scanf("%d%d", &n, &m);
	memset(d, 0x3f, sizeof(d));
	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;
		v.push_back({ 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 cnt = 0;
	for (st s : v) {
		if (d[s.a][s.b] != s.c)cnt++;
	}
	printf("%d\n", cnt);
}