#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main () {
    string s, t;
    cin >> s >> t;
    vector<int> a(26, 0), b(26, 0);
    for (int i = 0; i < s.size(); i++) {
        a[s[i] - 'a']++;
        b[t[i] - 'a']++;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}