from itertools import combinations
from collections import defaultdict

N,M=map(int,input().split())
paths_dict={n:set() for n in range(1,N+1)}#key:int value:set of (int as point_num,int as dist)
all_paths=set()#set of tuples
for m in range(1,M+1):
    a,b,c=map(int,input().split())
    paths_dict[a].add((b,c))
    paths_dict[b].add((a,c))
    all_paths.add((min(a,b),max(a,b)))

pairs=set(combinations(range(1,N+1),2))#set of tuples
while pairs!=set():
    start,goal=pairs.pop()
    visited_dict=defaultdict(lambda: [set(),1+max(visited_dict[visited][1] for visited in visited_dict)])
    visited_dict[start]=[{0},0]#key:int value:[{int as former_point},int as dist_from_start]
    ends={start:[{0},0]}#key:int value:[int as former_point,int as dist_from_start]

    while ends!={} and visited_dict[goal][1]>min(ends[end][1] for end in ends):
        frontier={}#key:int value:[{ints as former_points},int as dist_from_start]
        for end in (end for end in ends if ends[end][1]<visited_dict[goal][1]):
            for num_dist in [num_dist for num_dist in paths_dict[end]]:
                if num_dist[0] in visited_dict:
                    if num_dist[0] in frontier:
                        if ends[end][1]+num_dist[1]<frontier[num_dist[0]][1]:
                            frontier[num_dist[0]]=[{end},ends[end][1]+num_dist[1]]
                        elif ends[end][1]+num_dist[1]==frontier[num_dist[0]][1]:
                            frontier[num_dist[0]][0].add(end)
                    else:
                        if ends[end][1]+num_dist[1]<visited_dict[num_dist[0]][1]:
                            visited_dict[num_dist[0]]=[{end},ends[end][1]+num_dist[1]]
                        elif ends[end][1]+num_dist[1]==visited_dict[num_dist[0]][1]:
                            visited_dict[num_dist[0]][0].add(end)
                else:
                    frontier[num_dist[0]]=[{end},ends[end][1]+num_dist[1]]
        visited_dict.update(frontier)
        ends=frontier

    used_paths=set()
    used_pairs=set()
    points={goal}
    while points!=set():
        former_points=set()
        for point in points:
            if point!=start:
                for former_point in visited_dict[point][0]:
                    former_points.add(former_point)
                    used_paths.add((min(former_point,point),max(former_point,point)))
                    used_pairs|={(min(former_point,point),max(former_point,point)),(min(former_point,goal),max(former_point,goal))}
        points=former_points
    all_paths-=used_paths
    pairs-=used_pairs

print(len(all_paths))
