# https://atcoder.jp/contests/abc051/tasks/abc051_d
# 考えたこと
# 1.warshal floydからの経路復元でやってみる

import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate
from copy import deepcopy


def read_ints():
    return list(map(int, read().split()))


INF = 10**9
N, M = read_ints()
adj_mat = [[INF] * N for _ in range(N)]
for _ in range(M):
    a, b, c = read_ints()
    a -= 1
    b -= 1
    adj_mat[a][b] = c
    adj_mat[b][a] = c
for i in range(N):
    adj_mat[i][i] = 0

D = deepcopy(adj_mat)
# warshal floyd
for k in range(N):
    for i in range(N):
        if D[i][k] >= INF:  # 定数倍高速化
            # ノード同士がつながってなければ更新しない
            continue
        for j in range(N):
            D[i][j] = min(D[i][j], D[i][k] + D[k][j])

# print(*adj_mat, sep='\n')

# 経路復元


def restore_path(s: int, t: int, adj_mat: list, D: list):
    '''
    s→tまでの最短経路を復元する
    adj_mat
    '''
    ret = []  # 経路
    cur = s
    while cur != t:
        for i in range(N):
            if i != cur and adj_mat[cur][i] + D[i][t] == D[cur][t]:
                ret.append((cur, i) if cur < i else (i, cur))  # 大小関係をはっきりさせておく
                cur = i
                break
    return ret


#
from itertools import combinations
edges = set()
for s, t in combinations(range(N), 2):
    edges |= set(restore_path(s, t, adj_mat, D))
print(M - len(edges))
