def score_n2(matrix, matrix_size):
    """    Implements the penalty score feature 2.

    ISO/IEC 18004:2015(E) -- 7.8.3 Evaluation of data masking results - Table 11 (page 54)

    ==============================   ====================   ===============
    Feature                          Evaluation condition   Points
    ==============================   ====================   ===============
    Block of modules in same color   Block size = m × n     N2 ×(m-1)×(n-1)
    ==============================   ====================   ===============

    N2 = 3

    :param matrix: The matrix to evaluate
    :param matrix_size: The width (or height) of the matrix.
    :return int: The penalty score (feature 2) of the matrix.
    """
    score = 0
    for i in range(matrix_size - 1):
        for j in range(matrix_size - 1):
            bit = matrix[i][j]
            if bit == matrix[i][j + 1] and bit == matrix[i + 1][j
                ] and bit == matrix[i + 1][j + 1]:
                score += 1
    return score * 3
