#!/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)]
used_edge_map = [ [-1]*V for _ 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

    used_edge_map[s-1][t-1] = 0
    used_edge_map[t-1][s-1] = 0

s = set()

d = [ [inf]*V for _ in range(V)]
for i in range(V):
    for j in range(V):
        for k in range(V):
            # if c2 > vertices[j][k] + vertices[k][i]:
            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
        
        # make edge
        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]:
                     ss.add( (i,j) )
# print(ss)
                



        # if i == j: continue
        
        

# for i in range(V):
#     for j in range(V):
#         c2 = vertices[j][i]
#         for k, (c1,c3) in enumerate(zip(vertices[j], vertices[i])):
#             if c1 > c2+c3:
#                 s.add( (j,k) ) # $B:GC;7PO)(B
#                 vertices[j][k] = c2+c3
#             # if c1 <= c2+c3:
#             #     s.add( (j,k) ) # $B:GC;7PO)(B
#             #     vertices[j][k] = c1 #  c2+c3


# print(s)
ans =  2*E
ans = ans - len(ss)
ans = ans // 2

print(ans)

