#include <fstream>

using namespace std;

void shift(char *in, char *out, int n)
{
	int i;
	for (i = 0; in[i] != '\0'; ++i)
	{
		out[i] = in[i] + n;
		if (out[i] > 'Z')
			out[i] -= 26;
	}
	out[i] = '\0';
}

void count(char *str, int c[])
{
	for (int i = 0; i < 26; ++i)
	{
		c[i] = 0;
	}
	for (int j = 0; str[j] != '\0'; ++j)
		++c[str[j] - 'A'];
}

int main()
{
	ifstream in("ancient.in");
	ofstream out("ancient.out");

	char s1[200], s2[200], s3[200];
	int c1[26], c2[26], c3[26];
	int i;

	in >> s1 >> s2;

	count(s1, c1);
	count(s2, c2);


	for (i=1; i<26; i++)
		for (int j=0; j<i; j++)
		{
			if (c1[i] < c1[j])
			{
				int t = c1[i];
				c1[i] = c1[j];
				c1[j] = t;
			}

			if (c2[i] < c2[j])
			{
				int t = c2[i];
				c2[i] = c2[j];
				c2[j] = t;
			}
		}

	bool match = true;
	for (int j = 0; j < 26; ++j)
		if (c1[j] != c2[j])
			match = false;


/*	bool match = false;

	for (i = 0; i < 26; ++i)
	{
		shift(s1, s2, i);
		count(s2, c2);
		match = true;
		for (int j = 0; j < 26; ++j)
			if (c3[j] != c2[j])
				match = false;
		if (match)
			break;
	}
*/
 	if (match)
		out << "YES\n";
	else
		out << "NO\n";

	in.close();
	out.close();

	return 0;
}