n,m=list(map(int,input().split()))

d=[[float('inf') for i in range(n)] for i in range(n)]

r=[list(map(int,input().split())) for i in range(m)]



def wf(d):

    for k in range(n):

        for i in range(n):

            for j in range(n):

                d[i][j]=min(d[i][j],d[i][k]+d[k][j])

    return d





for u,v,c in r:

    u,v=u-1,v-1

    d[u][v]=d[v][u]=c



wf(d)



cnt=0

for u,v,c in r:

    u,v=u-1,v-1

    if d[u][v]!=c:

        cnt+=1

print(cnt)
n,m=list(map(int,input().split()))

d=[[float('inf') for i in range(n)] for i in range(n)]

r=[list(map(int,input().split())) for i in range(m)]



from scipy.sparse.csgraph import floyd_warshall



for u,v,c in r:

    u,v=u-1,v-1

    d[u][v]=d[v][u]=c



d=floyd_warshall(d).tolist()



cnt=0

for u,v,c in r:

    u,v=u-1,v-1

    if d[u][v]!=c:

        cnt+=1

print(cnt)
n, m = list(map(int, input().split()))
d = [[float("inf") for i in range(n)] for i in range(n)]
r = [list(map(int, input().split())) for i in range(m)]


def wf(d):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d


for u, v, c in r:
    u, v = u - 1, v - 1
    d[u][v] = d[v][u] = c
wf(d)
cnt = 0
for u, v, c in r:
    u, v = u - 1, v - 1
    if d[u][v] != c:
        cnt += 1
print(cnt)

n, m = list(map(int, input().split()))
d = [[float("inf") for i in range(n)] for i in range(n)]
r = [list(map(int, input().split())) for i in range(m)]
from scipy.sparse.csgraph import floyd_warshall

for u, v, c in r:
    u, v = u - 1, v - 1
    d[u][v] = d[v][u] = c
d = floyd_warshall(d).tolist()
cnt = 0
for u, v, c in r:
    u, v = u - 1, v - 1
    if d[u][v] != c:
        cnt += 1
print(cnt)

- - -def wf(d): -    for k in range(n): -        for i in range(n): -            for j in range(n): -                d[i][j] = min(d[i][j], d[i][k] + d[k][j]) -    return d - +from scipy.sparse.csgraph import floyd_warshall -wf(d) +d = floyd_warshall(d).tolist()