#!/usr/bin/env python3
import copy
N, M = map(int, input().split())
G = [[10**9 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

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 j <= i:
            continue
        flag = False
        for k in range(N):
            if i == k or k == j:
                continue
            if G_raw[i][j] != 10**9 and G_raw[k][i] != 10**9 and G_raw[k][j] != 10 ** 9 and G[k][i] + G_raw[i][j] != G[k][j]:
                flag = True
                break
        if flag:
            ans += 1

print(ans)
