import copy
n, m = map(lambda x: int(x), input().split())
a = [0] * m
b = [0] * m
c = [0] * m
for i in range(m):
    a[i], b[i], c[i] = map(lambda x: int(x), input().split())

dist = [[-1 for i in range(n+1)] for j in range(n+1)]
for i in range(1, n+1):
    dist[i][i] = 0
    hist = [i]
    while True:
        hist_tmp = []
        for h in hist:
            for j in range(m):
                if a[j] == h and (dist[i][b[j]] == -1 or dist[i][b[j]] > dist[i][a[j]] + c[j]):
                    dist[i][b[j]] = dist[i][a[j]] + c[j]
                    hist_tmp.append(b[j])
                elif b[j] == h and (dist[i][a[j]] == -1 or dist[i][a[j]] > dist[i][b[j]] + c[j]):
                    dist[i][a[j]] = dist[i][b[j]] + c[j]
                    hist_tmp.append(a[j])
        if hist_tmp == []:
            break
        else:
            hist = copy.copy(hist_tmp)

count = 0
for i in range(m):
    if dist[a[i]][b[i]] < c[i]:
        count += 1
print(count)