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

ifstream in("ancient.in");
ofstream out("ancient.out");

int main()
{
	char str1[200];
	char str2[200];

	vector<int> g1(26),g2(26);

	in >> str1;
	in >> str2;

	int i;

	if (strlen(str1)!=strlen(str2) )
	{
		out << "NO\n";
		return 0;
	}

	for (i=0;i<strlen(str1);i++)
	{
		++g1[str1[i]-'A'];
		++g2[str2[i]-'A'];
	}

	sort (g1.begin(), g1.end());
	sort (g2.begin(), g2.end());

	for (i=0;i<26;i++)
		if (g1[i]!=g2[i])
		{
			out << "NO\n";
			return 0;
		}

	out << "YES\n";

	return 0;
}