V,E = map(int, input().split())

inf = float("inf")
edges = [[inf if i!=j else 0 for j in range(V)] for i in range(V)]
ee = []

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


d = [ [inf]*V for _ in range(V)]
for i in range(V):
    d[i][i] = 0

for i in range(E):
    # print(len(ee))
    # exit(0)
    d[ee[i][0]][ee[i][1]] = min(d[ee[i][0]][ee[i][1]] , ee[i][2])
    d[ee[i][1]][ee[i][0]] = min(d[ee[i][1]][ee[i][0]] , ee[i][2])

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



ss = set()

ans = E
for i in range(E):
    e1,e2 = ee[i][:2]
    shortest = False

    try:

        for s in range(V):
            for t in range(V):
        
                if d[s][t] == d[s][e1] + edges[e1][e2] + d[e2][t]:
                    ans -= 1
                    raise "a"
                # ss.add( (e1, e2) )
    except:
        pass


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

print(ans)

