#!/usr/bin/env python3
N, M = map(int, input().split())
G = [[0 for _ in range(N)] for _ in range(N)]
for _ in range(M):
    tmp_a, tmp_b, tmp_c = map(int, input().split())
    G[tmp_a-1][tmp_b-1] = tmp_c
    G[tmp_b-1][tmp_a-1] = tmp_c

import copy
G_raw = copy.deepcopy(G)
for k in range(N):
    for i in range(N):
        for j in range(N):
            if G[i][k] + G[k][j] <= G[i][j]:
                G[i][j] = G[i][k] + G[k][j]
ans = 0
for i in range(N):
    for j in range(N):
        if G_raw[i][j] != G[i][j]:
            ans += 1

print(ans//2)

