#include<iostream>
#include<unordered_map>
using namespace std;
class Isomorphicchecker{
    public:
    bool areIsomorphic(string a,string b){
        if(a.size()!=b.size())return false;
        unorderede_map<char,char>m1,m2;
        for(int i=0;i<a.size();i++)
        if((m1[a[i]]&&m1[a[i]]!=b[i])||(m2[b[i]]&&m2[b[i]]!=a[i]))return false;
        else m1[a[i]]=b[i],m2[b[i]]=a[i];
        return true;
    }
};
int main(){
    string s1,s2;
    cin>>s1>s2;
    cout<<(Isomorphicchecker().areIsomorphic(s1,s2)?"True":"False");
}