Function to count the number of nodes with red color
def countRed ( color , n ) : NEW_LINE INDENT red = 0 ; NEW_LINE for i in range ( n ) : NEW_LINE INDENT if ( color [ i ] == 1 ) : NEW_LINE INDENT red += 1 ; NEW_LINE DEDENT DEDENT return red ; NEW_LINE DEDENT