# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import string

INF = 32768

def main():
    lines = map(lambda x: [int(i) for i in string.split(x)],
        sys.stdin.readlines())
    N, M = lines[0]

    d = [[INF]*N for x in range(N)]
    for i in range(N):
        for j in range(N):
            if(i == j): d[i][j] = 0

    for line in lines[1:]:
        d[line[0]-1][line[1]-1] = line[2]
        d[line[1]-1][line[0]-1] = line[2]

    # Warshall–Floyd Algorithm
    for k in range(N):
        for i in range(N):
            for j in range(N):
                if(d[i][k] != INF and d[k][j] != INF):
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j])

    count = 0
    for line in lines[1:]:
        i, j, c = line
        #print("%s %s org:%s calc:%s" % (i,j,c,d[i-1][j-1]))
        if(d[i-1][j-1] != c):
            count += 1
            

    sys.stdout.write("%s" % count)

if __name__ == '__main__':
    main()
