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

ifstream fi("ancient.in");
ofstream fo("ancient.out");
typedef vector<int> veci;typedef vector<double> vecd;typedef vector<string> vecs;

#define forn(i,n) if(true)for(int i=0;i<(n);i++)
#define feach(i,v) forn(i,((int)v.size()))
#define VA(v) v.begin(),v.end()

veci v1,v2;

int main(){
	string a,b;
	fi>>a>>b;

	v1.resize(256);fill(VA(v1),0);
	v2.resize(256);fill(VA(v2),0);
	feach(i,a){
		unsigned char val=a[i];
		v1[val]++;
	}
	feach(i,b){
		unsigned char val=b[i];
		v2[val]++;
	}
	sort(VA(v1));
	sort(VA(v2));
	if(v1==v2)
		fo<<"YES";
	else
		fo<<"NO";
	return 0;
}