#include <stdio.h>
#include <string.h>
#include <algorithm>

using namespace std;
char s1[256], s2[256];
int cnt1[256], cnt2[256];

int main(void)
{
int i;
  freopen("ancient.in",  "rt", stdin);
  freopen("ancient.out", "wt", stdout);
  gets(s1);
  gets(s2);
  for(i = 0; s1[i]; i++) ++cnt1[s1[i]-'A'];
  for(i = 0; s2[i]; i++) ++cnt2[s2[i]-'A'];
  stable_sort(cnt1, cnt1+256);
  stable_sort(cnt2, cnt2+256);
  for(i = 0; i < 256; i++) if(cnt1[i] != cnt2[i]) break;
  if(i == 256) printf("YES\n");
  else printf("NO\n");
  return 0;
}