class Solution:
    def canConstruct(self, ransomNote: str, magazine: str) -> bool:
        if len(ransomNote) > len(magazine):
            return False
        d1 = dict()
        d2 = dict()

        for i in ransomNote:
            d1[i] = d1.get(i, 0) + 1
        for i in magazine:
            d2[i] = d2.get(i, 0) + 1

        for k, v in d1.items():
            if k not in d2:
                return False
            if v > d2[k]:
                return False
        return True


if __name__ == '__main__':
    s = Solution()

    ransomNote = "aa"
    magazine = "aab"
    print(s.canConstruct(ransomNote, magazine))