#include <iostream>
#include <string>
#include <cstring> // for memset
#include <algorithm>
using namespace std;
int main()
{
int ce[26], co[26];
string encrypted, orginal;
string::size_type i, len;
ios::sync_with_stdio(false);
while (cin >> encrypted >> orginal)
{
memset(ce, 0, sizeof(ce));
memset(co, 0, sizeof(co));
len = orginal.length();
for (i = 0; i < len; ++i)
{
++ce[encrypted[i]-'A'];
++co[orginal[i]-'A'];
}
sort(ce, ce+26);
sort(co, co+26);
if (equal(ce, ce+26, co))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}