# coding: utf-8
n,m=map(int,input().split())
v=[[0 for i in range(n)] for i in range(n)]
used=[[0 for i in range(n)] for i in range(n)]
cost_table=[[99999999 for i in range(n)] for i in range(n)]
for i in range(m):
    a,b,c=map(int,input().split())
    v[a-1][b-1]=1
    v[b-1][a-1]=1
    cost_table[a-1][b-1]=c
    cost_table[b-1][a-1]=c

init_cost_table=[]
for i in range(n):
    init_cost_table.append(cost_table[i][:])

for i in range(n):
    for j in range(n):
        for k in range(n):
            if cost_table[i][k]>cost_table[i][j]+cost_table[j][k]:
                cost_table[i][k]=cost_table[i][j]+cost_table[j][k]
    cost_table[i][i]=0

memo={}
def Path(start,goal):
    cur = start;
    while cur != goal:
        if (cur,goal) in memo:
            break
        else:
            memo[(cur,goal)]=1
        for i in range(n):
            if (i != cur and init_cost_table[cur][i] + cost_table[i][goal] == cost_table[cur][goal]):
                used[cur][i]=1
                used[i][cur]=1
                cur = i
                break
for i in range(n):
    for j in range(n):
        Path(i,j)
ans=0
for i in range(n):
    ans+=sum(v[i])
for i in range(n):
    ans-=sum(used[i])
if ans//2 <0:
    while 1:
        pass
print(ans//2)

