#include <iostream>
#include <map>
#include <set>
#include <string>
using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;

    map<char, int> ms, mt;
    for (auto c : S) ms[c]++;
    for (auto c : T) mt[c]++;

    multiset<int> ss, st;
    for (auto e : ms) ss.insert(e.second);
    for (auto e : mt) st.insert(e.second);
    cout << (ss == st ? "Yes" : "No") << endl;
}
