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 (i; 0 .. 26)
    {
        long row, col;
        foreach (j; 0 .. 26)
        {
            if (table[i][j]) ++row;
            if (table[j][i]) ++col;
        }

        if (row > 1 || col > 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;