def main():

    from itertools import combinations

    import sys

    input = sys.stdin.readline



    inf = 1000 * 100 + 10



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



    dist = [[[inf, 0] for _ in range(N)] for _ in range(N)]

    for j in range(N):

        dist[j][j] = [0, 0]



    for idx in range(M):

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

        a -= 1

        b -= 1

        dist[a][b][0] = dist[b][a][0] = c

        dist[a][b][1] = dist[b][a][1] = 1 << idx  # weight,edge_idx



    for k in range(N):

        for i in range(N):

            for j in range(N):

                nd = dist[i][k][0] + dist[k][j][0]

                if dist[i][j][0] > nd:

                    dist[i][j][0] = nd

                    dist[i][j][1] = dist[i][k][1] | dist[k][j][1]

                elif dist[i][j][0] == nd:

                    dist[i][j][1] |= dist[i][k][1] | dist[k][j][1]



    used_edge = 0

    for frm, to in combinations(list(range(N)), r=2):

        used_edge |= dist[frm][to][1]



    print((M - bin(used_edge).count('1')))





if __name__ == '__main__':

    main()

# https://atcoder.jp/contests/abc051/submissions/1055446



def main():

    import sys

    input = sys.stdin.readline



    inf = 1000 * 100 + 10



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



    dist = [[inf for _ in range(N)] for _ in range(N)]

    for j in range(N):

        dist[j][j] = 0



    es = []

    for _ in range(M):

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

        a -= 1

        b -= 1

        es.append((a, b, c))

        dist[a][b] = dist[b][a] = c



    for k in range(N):

        for i in range(N):

            for j in range(N):

                d = dist[i][k] + dist[k][j]

                if dist[i][j] > d:

                    dist[i][j] = d



    ans = 0

    for a, b, c in es:

        if dist[a][b] == c: continue

        ans += 1

    print(ans)





if __name__ == '__main__':

    main()

def main():
    from itertools import combinations
    import sys

    input = sys.stdin.readline
    inf = 1000 * 100 + 10
    N, M = list(map(int, input().split()))
    dist = [[[inf, 0] for _ in range(N)] for _ in range(N)]
    for j in range(N):
        dist[j][j] = [0, 0]
    for idx in range(M):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        dist[a][b][0] = dist[b][a][0] = c
        dist[a][b][1] = dist[b][a][1] = 1 << idx  # weight,edge_idx
    for k in range(N):
        for i in range(N):
            for j in range(N):
                nd = dist[i][k][0] + dist[k][j][0]
                if dist[i][j][0] > nd:
                    dist[i][j][0] = nd
                    dist[i][j][1] = dist[i][k][1] | dist[k][j][1]
                elif dist[i][j][0] == nd:
                    dist[i][j][1] |= dist[i][k][1] | dist[k][j][1]
    used_edge = 0
    for frm, to in combinations(list(range(N)), r=2):
        used_edge |= dist[frm][to][1]
    print((M - bin(used_edge).count("1")))


if __name__ == "__main__":
    main()

# https://atcoder.jp/contests/abc051/submissions/1055446
def main():
    import sys

    input = sys.stdin.readline
    inf = 1000 * 100 + 10
    N, M = list(map(int, input().split()))
    dist = [[inf for _ in range(N)] for _ in range(N)]
    for j in range(N):
        dist[j][j] = 0
    es = []
    for _ in range(M):
        a, b, c = list(map(int, input().split()))
        a -= 1
        b -= 1
        es.append((a, b, c))
        dist[a][b] = dist[b][a] = c
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d = dist[i][k] + dist[k][j]
                if dist[i][j] > d:
                    dist[i][j] = d
    ans = 0
    for a, b, c in es:
        if dist[a][b] == c:
            continue
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

+# https://atcoder.jp/contests/abc051/submissions/1055446 -    from itertools import combinations -    dist = [[[inf, 0] for _ in range(N)] for _ in range(N)] +    dist = [[inf for _ in range(N)] for _ in range(N)] -        dist[j][j] = [0, 0] -    for idx in range(M): +        dist[j][j] = 0 +    es = [] +    for _ in range(M): -        dist[a][b][0] = dist[b][a][0] = c -        dist[a][b][1] = dist[b][a][1] = 1 << idx  # weight,edge_idx +        es.append((a, b, c)) +        dist[a][b] = dist[b][a] = c -                nd = dist[i][k][0] + dist[k][j][0] -                if dist[i][j][0] > nd: -                    dist[i][j][0] = nd -                    dist[i][j][1] = dist[i][k][1] | dist[k][j][1] -                elif dist[i][j][0] == nd: -                    dist[i][j][1] |= dist[i][k][1] | dist[k][j][1] -    used_edge = 0 -    for frm, to in combinations(list(range(N)), r=2): -        used_edge |= dist[frm][to][1] -    print((M - bin(used_edge).count("1"))) +                d = dist[i][k] + dist[k][j] +                if dist[i][j] > d: +                    dist[i][j] = d +    ans = 0 +    for a, b, c in es: +        if dist[a][b] == c: +            continue +        ans += 1 +    print(ans)