n, m = list(map(int, input().split()))
connect = {}
dist = {}
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    if not a in connect.keys(): connect[a] = [b]
    else: connect[a].append(b)
    if not b in connect.keys(): connect[b] = [a]
    else: connect[b].append(a)
    
    dist[tuple(sorted([a, b]))] = c

ans = 0
for s in range(1, n):
    for t in range(s+1, n+1):
        if not (s, t) in dist.keys():
            continue
        
        dists = [1000]*(n+1)
        dists[s] = 0
        stack = [(s, sc) for sc in connect[s]]
        while len(stack) > 0:
            s0, s1 = stack[0]
            stack = stack[1:]
            if dists[s0]+dist[tuple(sorted((s0, s1)))] >= dists[s1]:
                continue
            else:
                dists[s1] = dists[s0]+dist[tuple(sorted((s0, s1)))]
                for s2 in connect[s1]:
                    stack.append((s1, s2))
        # print(dists)
        if dists[t] < dist[(s, t)]:
            ans += 1

print(ans)