V, E = [int(_) for _ in input().split()]
G = {}
for i in range(V):
    G[i] = {}
    G[i][i] = 0

for _ in range(E):
    s, t, c = [int(_) for _ in input().split()]
    s -= 1  # 0を始点とする場合
    t -= 1  # 0を始点とする場合
    G[s][t] = c
    G[t][s] = c

INF = 10**10

D = [INF] * V
D[0] = 0  # 0を始点とする場合
used = [True] + [False] * (V - 1)
i = 0
prev = {}
while True:
    for j in G[i].keys():
        if D[i] + G[i][j] < D[j]:
            D[j] = D[i] + G[i][j]
            prev[j] = i
    v = -1
    for j in range(V):
        if not used[j] and (v == -1 or D[j] < D[v]):
            v = j
    if v == -1:
        break
    else:
        used[v] = True
        i = v

print(E - len(prev))