import sys
sys.setrecursionlimit(10000)

n, m = map(int, input().split())
abc = [tuple(int(x) - 1 for x in input().split()) for _ in range(m)]

#res = [[9999999 for _ in range(n)] for _ in range(n)]

e = [dict() for _ in range(n)]

for i in range(m):
    a, b, c = abc[i][0], abc[i][1], abc[i][2]
    e[a][b] = [c, i]
    e[b][a] = [c, i]

ans = set()

for i in range(n-1):
    for j in range(i + 1, n):
        temp = [[0, i]]
        res = []
        for k in range(n):
            next = []
            for x in temp:
                if x[1] == j:
                    res.append(x)
                    continue
                for z in e[x[1]].keys():
                    if len(x) == 2:
                        next.append([ x[0] + e[x[1]][z][0], z ] + [ e[x[1]][z][1] ])
                    else:
                        next.append([ x[0] + e[x[1]][z][0], z ] + x[2:] + [ e[x[1]][z][1] ])
            temp = [] + next
        mr = 99999999
        p = 0
        for i in range(len(res)):
            if res[i][0] < mr:
                mr = res[i][0]
                p = i
        #print(set(res[p][2:]))
        ans = ans | set(res[p][2:])

print(m - len(ans))