class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 
     * @param ransomNote string字符串 
     * @param magazine string字符串 
     * @return bool布尔型
     */
    bool canConstruct(string r, string m) {
        // write code here
        unordered_map<int,int>m1;
        unordered_map<int,int>m2;
         for(int i=0;i<r.size();i++)
         {
            m1[r[i]]++;
         }
         for(int i=0;i<m.size();i++)
         {
            m2[m[i]]++;
         }
         int count=0;
         for(auto m:m1)
         {
            if(m2.count(m.first))//判断m2中是否包含m1的所有键
            {
                int a=m2.at(m.first)-m.second;
                if(a>=0)//判断m2中键的值是否不小于m1
                {
                 count++;
                }
            }
            else {
            return false;
            cout<<0;
            }
         }
         if(count==m1.size())//当所有键都满足时
         {
            cout<<1;
            return true;
        
         }
         else {
            cout<<2;
         return false;
         }
    }
};