import sys
from collections import Counter, deque, defaultdict, OrderedDict
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, e = MAP()    
G = [[]for i in range(n)]   
G_table = [[0]*n for i in range(n)]
    
for i in range(e):
    fr, to, w = MAP()
    G_table[fr-1][to-1] = 1
    G_table[to-1][fr-1] = 1
    G[fr-1].append((w, to -1))
    G[to-1].append((w, fr -1))

def djkstra(s,G):
    visited = [False]*n    
    d = [INF]*n
    former = [INF]*n
    que = []
    heapq.heapify(que)
    heapq.heappush(que, (0,s,-1))

    while(len(que)>0):
        vs = heapq.heappop(que)
        distance = vs[0]
        vertex = vs[1]
        f = vs[2]
        if visited[vertex]:
            continue
        d[vertex] = distance
        visited[vertex] = True
        former[vertex] = f
        for Gs in G[vertex]:
            if d[Gs[1]] <= distance+Gs[0]:
                continue
            heapq.heappush(que,(distance+Gs[0], Gs[1], vertex))
    
    return d,former

res = 0

for k in range(n):
    d, former = djkstra(k,G)
    for i in range(n):
        if former[i] != -1:
            G_table[i][former[i]] = 0
            G_table[former[i]][i] = 0

for i in range(n):
    for j in range(n):
        if G_table[i][j] == 1:
            res += 1

print(res//2)