import sys
input = sys.stdin.readline

from collections import deque
import copy
n,m = map(int,input().split())
r = [[] for i in range(n)]
for i in range(m):
    a,b,c = map(int,input().split())
    r[a-1].append((b-1,c,i+1))
    r[b-1].append((a-1,c,i+1))

def bfs(x,y):
    q = deque([])
    l = [-1]*n
    l[x] = 0
    check =[[] for i in range(n)]
    q.append((x,0,[]))
    while q:
        bef,pas,rec = q.popleft()
        if bef == y:
            break
            

        for nex,c,num in r[bef]:
            rec2 = copy.deepcopy(rec)
            rec2.append(num)
            
            if l[nex] == -1:
                l[nex] = pas+c
                check[nex] = rec2
                q.append((nex,pas+c,rec2))
            else:
                
                if pas+c < l[nex]:  
                    l[nex] = pas+c
                    check[nex] = rec2
                elif pas+c == l[nex]:
                    check[nex].append(rec2)
                else:
                    continue
    return check[y]

ans = set()
for i in range(n):
    for j in range(n):
        for k in bfs(i,j):
            ans.add(k)
        if len(ans) == m:
            print(0)
            exit()
print(m-len(ans))



            