import sys from collections import deque,defaultdict import itertools import heapq import bisect import math #sys.setrecursionlimit(10 ** 9) input = lambda: sys.stdin.readline().rstrip() ii = lambda: int(input()) mi = lambda: map(int, input().split()) ml = lambda: map(str, input().split()) li = lambda: list(mi()) li_st = lambda: list(map(str, input().split())) lli = lambda n: [li() for _ in range(n)] mod = 998244353 A = input() B = input() for e in itertools.permutations(range(len(A))): lis = [] for i in e: lis.append(A[i]) s = "".join(lis) if s == B: print("YES") exit() print("NO")