# ABC051 D - Candidates of No Shortest Paths

si = lambda: eval(input())

ni = lambda: int(eval(input()))

nm = lambda: list(map(int, input().split()))

nl = lambda: list(map(int, input().split()))

def WF():

    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])



n,m=nm()

aa=[]

bb=[]

cc=[]

d=[[0]*n for i in range(n)]

for i in range(m):

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

    a-=1

    b-=1

    aa.append(a)

    bb.append(b)

    cc.append(c)

for i in range(n):

    for j in range(n):

        if i==j:

            d[i][j]=0

        else:

            d[i][j]=10**5



for i in range(m):

    d[aa[i]][bb[i]]=min(d[aa[i]][bb[i]],cc[i])

    d[bb[i]][aa[i]]=min(d[bb[i]][aa[i]],cc[i])

WF()



ans=m

for i in range(m):

    short=False

    for j in range(n):

        if d[j][aa[i]]+cc[i]==d[j][bb[i]]:

            short=True

    if short:

        ans-=1

print(ans)

N,M = list(map(int,input().split()))



A = []

B = []

C = []



for i in range(M):

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

    a -= 1

    b -= 1

    A.append(a)

    B.append(b)

    C.append(c)

inf = 10**18

dist = [[inf]*N for i in range(N)]



for i in range(N):

    for j in range(N):

        if i == j:

            dist[i][j] = 0



for i in range(M):

    dist[A[i]][B[i]] = C[i]

    dist[B[i]][A[i]] = C[i]



for k in range(N):

    for i in range(N):

        for j in range(N):

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

ans = 0

for i in range(M):

    if C[i] > dist[A[i]][B[i]]:

        ans += 1



print(ans)







# ABC051 D - Candidates of No Shortest Paths
si = lambda: eval(input())
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))


def WF():
    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])


n, m = nm()
aa = []
bb = []
cc = []
d = [[0] * n for i in range(n)]
for i in range(m):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    aa.append(a)
    bb.append(b)
    cc.append(c)
for i in range(n):
    for j in range(n):
        if i == j:
            d[i][j] = 0
        else:
            d[i][j] = 10**5
for i in range(m):
    d[aa[i]][bb[i]] = min(d[aa[i]][bb[i]], cc[i])
    d[bb[i]][aa[i]] = min(d[bb[i]][aa[i]], cc[i])
WF()
ans = m
for i in range(m):
    short = False
    for j in range(n):
        if d[j][aa[i]] + cc[i] == d[j][bb[i]]:
            short = True
    if short:
        ans -= 1
print(ans)

N, M = list(map(int, input().split()))
A = []
B = []
C = []
for i in range(M):
    a, b, c = list(map(int, input().split()))
    a -= 1
    b -= 1
    A.append(a)
    B.append(b)
    C.append(c)
inf = 10**18
dist = [[inf] * N for i in range(N)]
for i in range(N):
    for j in range(N):
        if i == j:
            dist[i][j] = 0
for i in range(M):
    dist[A[i]][B[i]] = C[i]
    dist[B[i]][A[i]] = C[i]
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])
ans = 0
for i in range(M):
    if C[i] > dist[A[i]][B[i]]:
        ans += 1
print(ans)

-# ABC051 D - Candidates of No Shortest Paths -si = lambda: eval(input()) -ni = lambda: int(eval(input())) -nm = lambda: list(map(int, input().split())) -nl = lambda: list(map(int, input().split())) - - -def WF(): -    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]) - - -n, m = nm() -aa = [] -bb = [] -cc = [] -d = [[0] * n for i in range(n)] -for i in range(m): +N, M = list(map(int, input().split())) +A = [] +B = [] +C = [] +for i in range(M): -    aa.append(a) -    bb.append(b) -    cc.append(c) -for i in range(n): -    for j in range(n): +    A.append(a) +    B.append(b) +    C.append(c) +inf = 10**18 +dist = [[inf] * N for i in range(N)] +for i in range(N): +    for j in range(N): -            d[i][j] = 0 -        else: -            d[i][j] = 10**5 -for i in range(m): -    d[aa[i]][bb[i]] = min(d[aa[i]][bb[i]], cc[i]) -    d[bb[i]][aa[i]] = min(d[bb[i]][aa[i]], cc[i]) -WF() -ans = m -for i in range(m): -    short = False -    for j in range(n): -        if d[j][aa[i]] + cc[i] == d[j][bb[i]]: -            short = True -    if short: -        ans -= 1 +            dist[i][j] = 0 +for i in range(M): +    dist[A[i]][B[i]] = C[i] +    dist[B[i]][A[i]] = C[i] +for k in range(N): +    for i in range(N): +        for j in range(N): +            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]) +ans = 0 +for i in range(M): +    if C[i] > dist[A[i]][B[i]]: +        ans += 1