from itertools import combinations as comb
from collections import deque as dq

def inpl(): return list(map(int, input().split()))


def dijkstra(a, b):
    node = dq()
    node.append(a)
    ncost = [1<<20 for _ in range(N+1)]
    first = a
    ncost[a] = 0
    path = {}
    while b not in node:
        for nb in edge[first]:
            if nb in node:
                continue
            if ncost[nb] > ncost[first] + cost[(first, nb)]:
                # print(nb, ncost[nb])
                path[nb] = first
                ncost[nb] = ncost[first] + cost[(first, nb)]
                # print(nb, ncost[nb])

        nf = 0
        # print(path)
        for t in range(N+1):
            if t in node:
                continue
            # print(nf, t)
            if ncost[nf] > ncost[t]:
                nf = t
        node.append(nf)
        first = nf
        # print(node)
    now = b
    # print(path)
    # print(ncost)
    ret = set()
    while True:
        if now == a:
            break
        ret.add((now, path[now]))
        ret.add((path[now], now))
        now = path[now]
    return ret


N, M = inpl()
cost = {}
edge = [dq() for _ in range(N+1)]
for _ in range(M):
    a, b, c = inpl()
    cost[(a, b)] = c
    cost[(b, a)] = c
    edge[a].append(b)
    edge[b].append(a)

ans = set()
for a, b, in comb([i for i in range(1, N+1)], 2):
    # print(a, b, "check")
    # print(dijkstra(a, b))
    ans = ans | dijkstra(a, b)
# print(ans)
print(M-len(ans)//2)