def warshall_floyd(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][j] > d[i][k] + d[k][j]: 
                    d[i][j] = d[i][k] + d[k][j]
    return d

n,w = map(int,input().split())
INF = 10**5
d = [[INF for i in range(n)] for i in range(n)]
e_list = []
for i in range(w):
    x,y,z = map(int,input().split())
    x -= 1
    y -= 1
    d[x][y] = z
    d[y][x] = z
    e_list.append([x,y,z])
for i in range(n):
    d[i][i] = 0

warshall_floyd(d)
ans = w
for x,y,z in e_list:
    ok = False
    for i in range(n):
        for j in range(n):
            if d[i][x] + z == d[y][j]:
                ans -= 1
                ok = True
                break
        if ok:
            break
print(ans)
    