#!/mnt/c/Users/moiki/bash/env/bin/python
V,E = map(int, input().split())
inf = float("inf")
vertices = [[inf if i!=j else 0 for j in range(V)] for i in range(V)]

for _ in [None]*E:
    s,t,cost  = map(int, input().split())
    vertices[s-1][t-1] = cost
    vertices[t-1][s-1] = cost


d = [ [inf]*V for _ in range(V)]
for i in range(V):
    for j in range(V):
        for k in range(V):
            d[j][i] = min( d[j][i], 
                    vertices[j][k] + vertices[k][i])


ss = set()
for s in range(V):
    for t in range(V):
        if s == t: continue

        # for i in range(V):
        #     # for j in range(V):
        #         # if i == j or vertices[i][j] == inf: continue
        #         if vertices[i][t] == inf: continue
        #         if d[s][t] == d[s][i] + vertices[i][t]:
        #             ss.add( (i,t) )

        for i in range(V):
            for j in range(V):
                if i == j or vertices[i][j] == inf: continue
                if d[s][t] == d[s][i] + vertices[i][j] \
                 + d[j][t]:
                     
                     if d[s][t] != inf:
                         ss.add( (i,j) )

ans =  2*E
ans = ans - len(ss)
ans = ans // 2

print(ans)

