#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D_fix
# CreatedDate:  2020-02-21 01:20:19 +0900
# LastModified: 2020-02-21 02:04:42 +0900
#


import os
import sys
import numpy as np
import heapq
#import pandas as pd
def make_matrix(matrix,a,b,c):
    matrix[a-1][b-1] = c
    matrix[b-1][a-1] = c
def initial_signal(i,matrix):
    d = [100]*(matrix.shape[0])
    d[i] = 0
    Q = []
    heapq.heappush(Q,(0,i))
    return d,Q

def relax(matrix,u,v,d,Q):
    if d[v] > d[u]+matrix[u][v]:
        d[v] = d[u]+matrix[u][v]
        heapq.heappush(Q, (d[v],v))


def dijkstra(i,matrix):
    d,Q = initial_signal(i,matrix)
    while Q:
        cost,u = heapq.heappop(Q)
        if d[u]<cost:
            continue
        for v in range(matrix.shape[0]):
            if matrix[u][v]!=0:
                relax(matrix,u,v,d,Q)
    return d
    

def main():
    N,M = map(int, input().split())
    matrix = np.zeros((N,N),dtype=np.int32)
    for _ in range(M):
        a,b,c = map(int,input().split())
        make_matrix(matrix,a,b,c)
    shortest = []
    for i in range(matrix.shape[0]):
        short = dijkstra(i,matrix)
        shortest.append(short)
    ans=0
    for i in range(N):
        for j in range(N):
            cost = matrix[i][j]
            if cost>shortest[i][j]:
                ans+=1

    print(ans//2)


if __name__ == "__main__":
    main()
