#include<fstream.h>
#include<string.h>

const int len = 105;

int main()
{
	ifstream cin("ancient.in");
	ofstream cout("ancient.out");
	char a[len],b[len];
	cin >> a >> b;
	int i;
	int aLen = strlen(a);
	int bLen = strlen(b);
	if (aLen != bLen)
	{
		cout << "NO";
		return 0;
	}
	int aMas[26] = {0}, bMas[26] = {0};
	bool used[26] = {false};
	for (i = 0; i < aLen; i++)
	{
		aMas[a[i]-'A']++;
		bMas[b[i]-'A']++;
	}
	for (i = 0; i < 26; i++)
	{
		bool a = false;
		for (int j = 0; j < 26; j++)
			if(!used[j] && aMas[i] == bMas[j]) 
			{
				used[j] = true;
				a = true;
				break;
			}
		if (!a)
		{
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	return 0;
}