from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,M = inpl()
cost = [[INF for i in range(N)] for j in range(N)]

#0:辺がない -1:辺はあるけど使ってない 1:使ってる
ed = [[0]*N for i  in range(N)]

for _ in range(M):
    a,b,c = inpl()
    a,b = a-1,b-1
    cost[a][b] = c
    cost[b][a] = c
    ed[a][b] = -1
    ed[b][a] = -1

for k in range(N):
    for i in range(N):
        for j in range(N):
            moto = cost[i][j]
            new = cost[i][k]+cost[k][j]
            if moto > new:
                if ed[i][j] != 0:
                    ed[i][j] = -1
                ed[i][k] = 1
                ed[k][j] = 1
                cost[i][j] = new

ans = 0
for i in range(N):
    for j in range(N):
        if ed[i][j] == -1:
            ans += 1
print(ans//2)
