#include <map>
#include <string>
class Solution {
  public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     *
     * @param s string字符串
     * @param c string字符串
     * @return int整型
     */
    int isCongruent(string s, string c) {
        // write code here
        if(s.size()!=c.size()) return -1;
        unordered_map<int, char> map1;
        unordered_map<int, char> map2;
        for (int i = 0; i < s.size(); i++) {
            if (map1.count(s[i])) {
                map1[s[i]]++;
            } else {
                map1[s[i]] = 1;
            }
        }
        for (int i = 0; i < c.size(); i++) {
            if (map2.count(c[i])) {
                map2[c[i]]++;
            } else {
                map2[c[i]] = 1;
            }
        }

        for (int i = 0; i < c.size(); i++) {
             if(map1[c[i]]!=map2[c[i]]){
                    return -1;
             }
        }
    
        return s.size();
    }
};