n,m=list(map(int, input().split()))
abc = []
for i in range(m):
    abc.append(list(map(int, input().split())))

bools = [False for i in range(n)]

dp =[[[0,[]] for i in range(n)] for i in range(n)]

for i in range(len(abc)):
    a=abc[i][0]
    b=abc[i][1]
    c=abc[i][2]
    a=a-1
    b=b-1
    dp[a][b][0]=dp[a][b][0]+c
    dp[b][a][0]=dp[b][a][0]+c
    dp[a][b][1]=[i]
    dp[b][a][1]=[i]

for i in range(n):
    for j in range(i,n):
        if dp[i][j][0]>0:
            for cand in range(n):
                if dp[i][cand][0]>0:
                    if dp[j][cand][0]>=dp[i][cand][0]+dp[i][j][0]:
                        dp[j][cand][0]=dp[i][cand][0]+dp[i][j][0]
                        dp[j][cand][1]=dp[i][cand][1]+dp[i][j][1]
                    if dp[i][cand][0]>=dp[j][cand][0]+dp[i][j][0]:
                        dp[i][cand][0]=dp[j][cand][0]+dp[i][j][0]
                        dp[i][cand][1]=dp[j][cand][1]+dp[i][j][1]

for i in range(n):
    for j in range(i,n):
        for x in dp[i][j][1]:
            bools[x]=True 

count=0
for i in range(n):
    if bools[i]==False:
        count+=1
print(count)