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

int main()
{

	std::string a, b;
	std::vector<int> ai(30), bi(30);
	std::ifstream in("ancient.in");
	std::ofstream out("ancient.out");
	std::string out_c = "NO";
	in >>a >>b;
	int len = a.length();
	
	{for (size_t i = 0;i < ai.size();i++) ai[i]=bi[i]=0;}
	
	for (int i = 0;i < len;i++)
	{
		ai[a[i]-'A']++;
		bi[b[i]-'A']++;
	}
		
	std::sort(ai.begin(), ai.end());
	std::sort(bi.begin(), bi.end());

	/*{for (size_t i = 0;i < ai.size();i++) std::cout <<ai[i] <<" ";};
	std::cout <<std::endl;
	{for (size_t i = 0;i < bi.size();i++) std::cout <<bi[i] <<" ";};*/
	if (ai == bi) out_c = "YES";
	out <<out_c;
	return 0;
}