#include <fstream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	ifstream in("ancient.in");
	ofstream out("ancient.out");
	string s1, s2;
	in >> s1 >> s2;
	in.close();
	string b = "QWERTYUIOPASDFGHJKLZXCVBNM";
	int l = b.length();
	vector <int> v1(l), v2(l);
	bool k = true;
	int l1 = s1.length();
	int l2 = s2.length();
	if(l1 != l2)
	{
		k = false;
		out << "NO";
		out.close();
		return 0;
	}
	int i, j;
	for(i = 0; i < l; i ++)
	{
		v1[i] = 0;
		v2[i] = 0;
	}
	for(i = 0; i < l1; i ++)
	{
		for(j = 0; j < l; j ++)
		{
			if(s1.at(i) == b.at(j))
				break;
		}
		v1[j] ++;
		for(j = 0; j < l; j ++)
		{
			if(s2.at(i) == b.at(j))
				break;
		}
		v2[j] ++;
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	for(i = 0; i < l; i ++)
	{
		if(v1[i] != v2[i])
			k = false;
	}
	if(k)
		out << "YES";
	else
		out << "NO";
	out.close();
	return 0;
}