from collections import Counter


class Solution:

    def countCharacters(self, words, chars):
        dic = Counter(chars)
        n = 0
        for word in words:
            good = True
            dic_c = Counter(word)
            for key, value in dic_c.items():
                if key not in dic.keys() or value > dic[key]:
                    good = False
                    break
            if good == True:
                n += len(word)
        return n

c984b671d2ef50d88212d046be39df582cbb4ab0
<mask token>

<mask token>


class Solution:
    <mask token>

<mask token>


class Solution:

    def countCharacters(self, words, chars):
        dic = Counter(chars)
        n = 0
        for word in words:
            good = True
            dic_c = Counter(word)
            for key, value in dic_c.items():
                if key not in dic.keys() or value > dic[key]:
                    good = False
                    break
            if good == True:
                n += len(word)
        return n

from collections import Counter


class Solution:

    def countCharacters(self, words, chars):
        dic = Counter(chars)
        n = 0
        for word in words:
            good = True
            dic_c = Counter(word)
            for key, value in dic_c.items():
                if key not in dic.keys() or value > dic[key]:
                    good = False
                    break
            if good == True:
                n += len(word)
        return n
