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

inf=float("inf")



r=lambda n:list(range(n))

l=[[inf if i!=j else 0 for j in r(n)] for i in r(n)]

a,b,c=[None]*m,[None]*m,[None]*m



for i in r(m):

  a[i],b[i],c[i]=list(map(int,input().split()))

  a[i]-=1

  b[i]-=1

  l[a[i]][b[i]]=c[i]

  l[b[i]][a[i]]=c[i]



for k in r(n):

  for i in r(n):

    for j in r(n):

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



ans=m

for i in r(m):

  f=False

  for j in r(n):

    if l[j][a[i]]+c[i]==l[j][b[i]]:

      f=True

  if f:ans-=1

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



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

d=[[float("inf")]*n for _ in range(n)]



for a,b,c in l:

  d[a-1][b-1]=c

  d[b-1][a-1]=c



for k in range(n):

  for i in range(n):

    for j in range(n):

      if i==j:d[i][j]=0

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



ans=m

for i,(a,b,c) in enumerate(l):

  f=False

  for s in range(n):

    if d[s][a-1]+c==d[s][b-1]:

      f=True

  if f:ans-=1



print(ans)
n, m = list(map(int, input().split()))
inf = float("inf")
r = lambda n: list(range(n))
l = [[inf if i != j else 0 for j in r(n)] for i in r(n)]
a, b, c = [None] * m, [None] * m, [None] * m
for i in r(m):
    a[i], b[i], c[i] = list(map(int, input().split()))
    a[i] -= 1
    b[i] -= 1
    l[a[i]][b[i]] = c[i]
    l[b[i]][a[i]] = c[i]
for k in r(n):
    for i in r(n):
        for j in r(n):
            l[i][j] = min(l[i][j], l[i][k] + l[k][j])
ans = m
for i in r(m):
    f = False
    for j in r(n):
        if l[j][a[i]] + c[i] == l[j][b[i]]:
            f = True
    if f:
        ans -= 1
print(ans)

n, m = list(map(int, input().split()))
l = [list(map(int, input().split())) for _ in range(m)]
d = [[float("inf")] * n for _ in range(n)]
for a, b, c in l:
    d[a - 1][b - 1] = c
    d[b - 1][a - 1] = c
for k in range(n):
    for i in range(n):
        for j in range(n):
            if i == j:
                d[i][j] = 0
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])
ans = m
for i, (a, b, c) in enumerate(l):
    f = False
    for s in range(n):
        if d[s][a - 1] + c == d[s][b - 1]:
            f = True
    if f:
        ans -= 1
print(ans)

-inf = float("inf") -r = lambda n: list(range(n)) -l = [[inf if i != j else 0 for j in r(n)] for i in r(n)] -a, b, c = [None] * m, [None] * m, [None] * m -for i in r(m): -    a[i], b[i], c[i] = list(map(int, input().split())) -    a[i] -= 1 -    b[i] -= 1 -    l[a[i]][b[i]] = c[i] -    l[b[i]][a[i]] = c[i] -for k in r(n): -    for i in r(n): -        for j in r(n): -            l[i][j] = min(l[i][j], l[i][k] + l[k][j]) +l = [list(map(int, input().split())) for _ in range(m)] +d = [[float("inf")] * n for _ in range(n)] +for a, b, c in l: +    d[a - 1][b - 1] = c +    d[b - 1][a - 1] = c +for k in range(n): +    for i in range(n): +        for j in range(n): +            if i == j: +                d[i][j] = 0 +            d[i][j] = min(d[i][j], d[i][k] + d[k][j]) -for i in r(m): +for i, (a, b, c) in enumerate(l): -    for j in r(n): -        if l[j][a[i]] + c[i] == l[j][b[i]]: +    for s in range(n): +        if d[s][a - 1] + c == d[s][b - 1]: