INF=100000000000


def dijkstra(s,t,adj,dist):
    to_visit = [s]
    visited=[False]*n
    d=[INF]*n
    d[s] = 0
    while len(to_visit) > 0:
        w = to_visit[0]
        for node in to_visit:
            if d[w] > d[node]:
                w = node

        if w == t:
            return d[w]
        to_visit.remove(w)
        visited[w]=True
        for node in adj[w]:
            if visited[node] == True:
                continue
            else:
                new_dist = d[w]+dist[w][node]
                if new_dist < d[node]:
                    d[node] = new_dist
                    to_visit.append(node)

    return INF




n,m = map(int,input().split())
dist=[[INF]*n for i in range(n)]
adj=[[] for i in range(n)]
D=[[INF]*n for i in range(n)]
edges=[]

for i in range(m):
    ai,bi,ci=map(int,input().split())
    edges.append(tuple([ai-1,bi-1,ci-1]))
    dist[ai-1][bi-1]=ci
    dist[bi-1][ai-1]=ci
    adj[ai-1].append(bi-1)
    adj[bi-1].append(ai-1)

for i in range(n):
    for j in range(n):
        D[i][j] = dijkstra(i,j,adj,dist)

#print(D)
count = 0
for edge in edges:
    ai,bi,ci=edge[0],edge[1],edge[2]
    flag = 0
    for s in range(n):
        if D[s][ai]+ci == D[s][bi]:
            flag+=1
            break

    if flag > 0:
        count+=1
    else:
        continue

print(count)
        