class Solution:
    def get_max_words(self, words, zeroes_count, ones_count):
        memo = [[0 for _ in range(ones_count + 1)] for _ in range(zeroes_count + 1)]

        for word in words:
            zeroes = sum([True for c in word if c == '0'])
            ones = len(word) - zeroes

            for i in range(zeroes_count + 1):
                for j in range(ones_count + 1):
                    can_build = i >= zeroes and j >= ones
                    if can_build:
                        memo[i][j] = max(memo[i][j], 1 + memo[i - zeroes][j - ones])
        
        return memo[-1][-1]

words = ["10", "0001", "111001", "1", "0"]
solution = Solution()
print(solution.get_max_words(words, 5, 3))