import sys
sys.setrecursionlimit(100000000)
n,k = map(int,input().split())
path = [[] for _ in range(n+1)]
mem = {}
rem_mem = set()
ans = []
for i in range(k):
    a,b,c = map(int,input().split())
    path[a].append(b)
    path[b].append(a)
    t = str(a)+'-'+str(b)
    mem[t] = c
    rem_mem.add(t)
    t = str(b) + '-' + str(a)
    mem[t] = c
def dfs(arr,node,end,cost):
    ar = arr[::]
    ar.append(node)
    for v in path[node]:
        if v not in arr:
            t = str(node)+'-'+str(v)
            if v == end:
                ans.append([cost+mem.get(t),ar+[v]])
            else:
                dfs(ar,v,end,cost+mem.get(t))
for i in range(1,n):
    ans =[]
    for j in range(i+1,n+1):
        dfs([],i,j,0)
        ans.sort()
        remove = ans[0][0]
        for _,v in ans:
            if _  == remove:
                for k in range(1,len(v)):
                    t = str(v[k-1])+'-'+str(v[k])
                    if t in rem_mem:
                        rem_mem.remove(t)
                    t = str(v[k])+'-'+str(v[k - 1])
                    if t in rem_mem:
                        rem_mem.remove(t)
print(len(rem_mem))