#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 50;
char s[N], t[N];
char mp1[256], mp2[256];
int main()
{
    scanf("%s%s", s, t);
    for (char *ps = s, *pt = t; *ps; ps++, pt++)
    {
        if (mp1[*ps] == 0 && mp2[*pt] == 0)
            mp1[*ps] = *pt, mp2[*pt] = *ps;
        if (mp1[*ps] != *pt || mp2[*pt] != *ps)
            return puts("No"), 0;
    }
    return puts("Yes"), 0;
}