def int_raw():
    return int(raw_input())

def ss_raw():
    return raw_input().split()

def ints_raw():
    return map(int,ss_raw())

INF = 1<<29

def make2d_arr(w,h,val =INF):
    return [[val]*w for i in xrange(h)]

def floyd_warshall(costs):
    N = len(costs)
    for k in xrange(N):
        for i in xrange(N):
            for j in xrange(N):
                costs[i][j]  = min(costs[i][j],costs[i][k]+costs[k][j])
    return costs

N,M = ints_raw()
costs = make2d_arr(N+1,N+1,INF)
E = []
for i in xrange(M):
    a,b,c = ints_raw()
    E.append((a,b,c))
    costs[a][b]=c
    costs[b][a]=c

costs = floyd_warshall(costs)

ans  = 0
for e in E:
    if costs[e[0]][e[1]] < e[2]:
        ans+=1
print ans




