better counting of matrix complexity