import sys
input = sys.stdin.readline
from copy import deepcopy

def main():
    N,M = map(int,input().split())
    INF = 10**6
    l = [[INF for _ in range(N)] for _ in range(N)]
    X = [list(map(int,input().split())) for _ in range(M)]
    for i in range(M):
        l[X[i][0]-1][X[i][1]-1] = X[i][2]
        l[X[i][1]-1][X[i][0]-1] = X[i][2]
    d = deepcopy(l)
    for i in range(N):
        for j in range(N):
            for k in range(N):
                d[i][k] = min(d[i][k],d[i][j]+d[j][k])

    count = 0
    for i in range(N):
        for j in range(N):
            if l[i][j] == d[i][j]:
                count += 1

    print(M-count//2)

if __name__ == "__main__":
    main()