#include <bits/stdc++.h>
using namespace std;

string fn(string s)
{
    string ret;
    int id = 'a';
    map<char, int> m;
    for (auto c : s) {
        if (m[c]) {
            ret += m[c];
        } else {
            m[c] = id++;
        }
    }
    return ret;
}
int main()
{
    string s, t;
    cin >> s >> t;

    cout << (fn(s) == fn(t) ? "Yes" : "No") << endl;

    return 0;
}
