n, m = map(int, input().split())
dis = [[float("inf") for i in range(n)] for j in range(n)]
for i in range(n):
    dis[i][i] = 0
abc = []
for i in range(m):
    a, b, c = map(int, input().split())
    abc.append([a, b])
    dis[a-1][b-1] = c
    dis[b-1][a-1] = c
flag = [[False for i in range(n)] for j in range(n)]
def warshall_floyd(dis):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dis1 = dis[i][j]
                dis2 = dis[i][k] + dis[k][j]
                if dis1 < dis2:
                    flag[i][j] = True
                    flag[j][i] = True
                dis[i][j] = min(dis1, dis2)
    return
warshall_floyd(dis)
ans = 0
for i in range(m):
    a, b = abc[i][0], abc[i][1]
    if flag[a-1][b-1] == False:
        ans += 1
print(ans)