#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

ifstream fin("ancient.in", ios::in);
ofstream fout("ancient.out", ios::out);

map<char, int> noccur;
vector<int> occurs1, occurs2;

int main(){

	string s;

	getline(fin, s);

	for (int i=0; i<s.length(); i++){
		char c=(char)s[i];

		noccur[c]++;
	}

	map<char, int>::iterator iter;
	
	for (iter=noccur.begin(); iter!=noccur.end(); iter++)
		occurs1.push_back(iter->second);

	noccur.clear();

	getline(fin, s);

	for (i=0; i<s.length(); i++){
		char c=(char)s[i];

		noccur[c]++;
	}

	for (iter=noccur.begin(); iter!=noccur.end(); iter++)
		occurs2.push_back(iter->second);

	sort(occurs1.begin(), occurs1.end());
	sort(occurs2.begin(), occurs2.end());

	int ans=0, count=0;

	if (occurs1.size()==occurs2.size()){
		for (i=0; i<occurs1.size(); i++)
			if (occurs1[i]==occurs2[i])
				count++;

		if (count==occurs1.size())
			ans=1;
	}

	if (ans==1)
		fout<<"YES";
	else
		fout<<"NO";

	return 0;
}