INF = 1000000

N, M = map(int, raw_input().split(" "))

dat = [[INF for _ in xrange(N)] for _ in xrange(N)]
isMinimal = [[True for _ in xrange(N)] for _ in xrange(N)]

for i in xrange(N):
    dat[i][i] = 0

a = [0 for _ in xrange(M)]
b = [0 for _ in xrange(M)]
c = [0 for _ in xrange(M)]
for i in xrange(M):
    a[i], b[i], c[i] = map(int, raw_input().split(" "))
    a[i] -= 1
    b[i] -= 1
    dat[a[i]][b[i]] = c[i]
    dat[b[i]][a[i]] = c[i]

for k in xrange(N):
    for i in xrange(N):
        for j in xrange(N):
            if dat[i][j] > dat[i][k] + dat[k][j]:
                dat[i][j] = dat[i][k] + dat[k][j]
                isMinimal[i][j] = False

res = 0
for i in xrange(M):
        res += 0 if isMinimal[a[i]][b[i]] else 1

print res
