void main()
{
    string s = readln.chomp;
    string t = readln.chomp;

    bool[26][26] table;
    foreach (i; 0 .. s.length)
    {
        table[s[i]-'a'][t[i]-'a'] = true;
    }

    bool ok = true;
    foreach (x; table)
    {
        long cnt;
        foreach (y; x)
        {
            if (y) ++cnt;
        }

        if (cnt > 1) ok = false;
    }

    writeln(ok ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;