#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <math.h>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define IREP(i,n) for (i = 0; i < (n); i++)

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

   string s1,s2;
   ifs >> s1 >> s2;

   VI a(300,0),b(300,0);

   int i;
   IREP(i,s1.size())
   {
      int cnt = 0;
      REP(j,s1.size())
         if (s1[i] == s1[j]) cnt++;
      a[cnt]++;
   }
   IREP(i,s2.size())
   {
      int cnt = 0;
      REP(j,s2.size())
         if (s2[i] == s2[j]) cnt++;
      b[cnt]++;
   }

   ofs << ((a == b) ? "YES" : "NO") << endl;

   return 0;
}