def main():
    def dijkstra_back(s,t):
        prev = [s] * n
        d = [float("inf")] * n
        used = [False] * n
        d[s] = 0
        while True:
            v = -1
            for i in range(n):
                if (not used[i]) and (v == -1):
                   v = i
                elif (not used[i]) and d[i] < d[v]:
                    v = i
            if v == -1:
                   break
            used[v] = True
            for i in range(n):
                if d[i] > d[v] + cost[v][i]: 
                    d[i] = d[v] + cost[v][i]
                    prev[i] = v
        path = [t]
        while prev[t] != s:
            path.append(prev[t])
            prev[t] = prev[prev[t]]
        path.append(s)
        path = path[::-1]
        return path
    
    n,m = map(int,input().split())
    route = [tuple(map(int,input().split())) for _ in range(m)]
    INF = float('inf')
    cost = [[INF for i in range(n)] for i in range(n)] 
    for i in route:
        cost[i[0]-1][i[1]-1] = i[2]
        cost[i[1]-1][i[0]-1] = i[2]
    
    used_ways = set([])
    for i in range(n):
        for j in range(n):
            if i < j:
                way = dijkstra_back(i,j)
                for k in range(len(way)-1):
                    used_ways.add(tuple(sorted([way[k],way[k+1]])))
    route_set = set([])
    for i in route:
        route_set.add(tuple(sorted([i[0]-1,i[1]-1])))
    print(len(route_set-used_ways))

if __name__ == '__main__':
    main()