N, M = map(int,raw_input().split())
INF = 10 ** 8
cost = [[INF for j in xrange(N+10)] for i in xrange(N+10)]
E = [[INF for j in xrange(N+10)] for i in xrange(N+10)]
for _ in xrange(M):
    a,b,c = map(int,raw_input().split())
    a -= 1
    b -= 1
    cost[a][b] = c
    cost[b][a] = c
    E[a][b] = c
    E[b][a] = c
for v in xrange(N):
    cost[v][v] = 0
for k in xrange(N):
    for i in xrange(N):
        for j in xrange(N):
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j])
ans = 0
for a in xrange(N):
    for b in xrange(a+1,N):
        if E[a][b] == INF:
            continue
        OK = False
        for s in xrange(N):
            for t in xrange(s+1,N):
                if cost[s][a] + E[a][b] + cost[b][t] == cost[s][t]:
                    OK = True
            if OK:
                break
        if not OK:
            ans += 1
print ans
