#!/usr/bin/env python3
import sys
import heapq
import copy

inf = float('inf')

def findedge(E, vv):
    e = (min(vv), max(vv))
    if e in E:
        return e
    return None


def dijkstra(V, E, L, s, g):
    D = [0 if v == s else inf for v in V]

    prev = [None for v in V]
    Q = [(d, v) for v, d in enumerate(D)]
    heapq.heapify(Q)

    while len(Q) > 0:
        u, du = heapq.heappop(Q)
        for v in V:
            e = findedge(E, (u, v))
            if not e:
                continue
            alt = du + L[e]
            if D[v] > alt:
                D[v] = alt
                prev[v] = u
                heapq.heappush(Q, (D[v], v))
    
    return D[g]


def solve(N: int, M: int, a: "List[int]", b: "List[int]", c: "List[int]"):
    V = list(range(N))
    E = set()
    L = dict()
    
    for i in range(M):
        e = tuple(sorted([a[i], b[i]]))
        E.add(e)
        L[e] = c[i]

    count = 0
    E2 = copy.deepcopy(E)
    for e in E:
        alt = dijkstra(V, E2, L, e[0], e[1])
        if alt < L[e]:
            count += 1
            E2.remove(e)

    print(count)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    c = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))-1
        b[i] = int(next(tokens))-1
        c[i] = int(next(tokens))
    solve(N, M, a, b, c)

if __name__ == '__main__':
    main()
