import sys
import heapq

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())

INF = 10 ** 18


def dijkstra(N, s0, edge):

    d = [INF] * N
    used = [False] * N
    edgelist = [(0, s0, -1)]
    heapq.heapify(edgelist)

    ret = set()
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        if used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = True

        if minedge[2] != -1:
            p = minedge[2]
            ret.add((min(p, v), max(p, v)))

        for e in edge[v]:
            if d[e[1]] < (e[0] + d[v]) or used[e[1]]:
                continue
            if d[e[1]] == (e[0] + d[v]) or used[e[1]]:
                ret.add((min(v, e[1]), max(v, e[1])))
                continue
            heapq.heappush(edgelist, (e[0] + d[v], e[1], v))

    return ret


def main():
    N, M = in_nn()
    edge = [[] for _ in range(N)]

    for i in range(M):
        a, b, c = in_nn()
        a, b = a - 1, b - 1
        edge[a].append((c, b))
        edge[b].append((c, a))

    used = set()
    for i in range(N):
        used |= dijkstra(N, i, edge)

    print(M - len(used))


if __name__ == '__main__':
    main()
