import std.stdio;
import std.ascii;
import std.conv;
import std.string;
import std.algorithm;
import std.range;
import std.functional;
import std.math;
import core.bitop;
import std.numeric;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void main()
{
    auto s = readln.chomp;
    auto t = readln.chomp;
    char[char] dict1;
    char[char] dict2;

    foreach (i; 0 .. s.length)
    {
        if (s[i] in dict1 && dict1[s[i]] != t[i])
        {
            writeln("No");
            return;
        }
        else
            dict1[s[i]] = t[i];

        if (t[i] in dict2 && dict2[t[i]] != s[i])
        {
            writeln("No");
            return;
        }
        else
            dict2[t[i]] = s[i];
    }
    writeln("Yes");
}
