import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
ulong MOD = 1_000_000_007;
ulong INF = 1_000_000_000_000;
alias SugarWater = Tuple!(long, "swater", long, "sugar");

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

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

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

auto charcount(string s)
{
    char current = s[0];
    auto ret = new long[](1);
    foreach (e; s)
    {
        if (e != current)
        {
            ret ~= [0];
            current = e;
        }
        ret[$ - 1]++;
    }
    return ret;
}

void main()
{
    auto s = sread();
    auto t = sread();
    char[char] trans;
    foreach (i; iota(s.length))
    {
        if (s[i] in trans)
        {
            if (trans[s[i]] != t[i])
            {
                writeln("No");
                return;
            }
        }
        else
        {
            trans[s[i]] = t[i];
        }
    }
    auto check = new long[](26);
    foreach (e; trans)
        check[e - 'a']++;

    foreach (e; check)
    {
        if (e > 1)
        {
            writeln("No");
            return;
        }
    }
    writeln("Yes");
}