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を始点とする場合
edges_used = set()
for i in range(V):
    used = [False] * V
    used[i] = True
    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
    for key, value in prev.items():
        if key > value:
            key, value = value, key
        edges_used.add(key * V + value)

print(E - len(edges_used))