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)]

dist = [[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 + 1
    e[b][a] = c + 1

for i in range(n-1):
    for j in range(i + 1, n):
        dp = [9999999 for _ in range(n)]
        dp[i] = 0
        temp = set()
        temp.add(i)
        while j not in temp:
            next = -1
            nc = 99999999
            for x in temp:
                for y in e[x].keys():
                    if y in temp:
                        continue
                    if dp[x] + e[x][y] < nc:
                        nc = dp[x] + e[x][y]
                        next = y
            temp.add(next)
            dp[next] = nc
            #print(temp, dp)
        dist[i][j] = dp[j]
        dist[j][i] = dp[j]

for i in range(n):
    dist[i][i] = 0

ans = m
for a, b, c in abc:
    for i in range(n):
        if c + 1 == dist[a][i] - dist[b][i]:
            ans -= 1
            break
print(ans)