#from statistics import median

#import collections

#aa = collections.Counter(a) # list to list

#from itertools import combinations # (string,3) 3回



mod = 10**9 + 7



def readInts():

  return list(map(int,input().split()))

def main():

    # S: azzel

    # T: apple

    S = eval(input())

    T = eval(input())

    ok = True

    dic_s = {}

    dic_t = {}

    for i in range(len(S)):

        s = S[i]

        t = T[i]

        if s in list(dic_s.keys()):

            if dic_s[s] != t:

                ok = False

        if t in list(dic_t.keys()):

            if dic_t[t] != s:

                ok = False

        dic_s[s] = t

        dic_t[t] = s

        #print(dic_s,dic_t,sep='\n')

    if ok:

        print('Yes')

    else:

        print('No')







if __name__ == '__main__':

  main()

#from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

#from itertools import combinations # (string,3) 3回

#from collections import deque

#import collections.defaultdict(list)

#import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#



mod = 10**9 + 7



def readInts():

  return list(map(int,input().split()))

def main():

    S = eval(input())

    T = eval(input())

    dic_s = {}

    dic_t = {}

    for i in range(len(S)):

        s = S[i]

        t = T[i]

        if s in dic_t:

            if dic_t[s] != t:

                print('No')

                exit()

        if t in dic_s:

            if dic_s[t] != s:

                print('No')

                exit()

        dic_t[s] = t

        dic_s[t] = s

    print('Yes')

if __name__ == '__main__':

  main()

# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list
# from itertools import combinations # (string,3) 3回
mod = 10**9 + 7


def readInts():
    return list(map(int, input().split()))


def main():
    # S: azzel
    # T: apple
    S = eval(input())
    T = eval(input())
    ok = True
    dic_s = {}
    dic_t = {}
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if s in list(dic_s.keys()):
            if dic_s[s] != t:
                ok = False
        if t in list(dic_t.keys()):
            if dic_t[t] != s:
                ok = False
        dic_s[s] = t
        dic_t[t] = s
        # print(dic_s,dic_t,sep='\n')
    if ok:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
# from itertools import combinations # (string,3) 3回
# from collections import deque
# import collections.defaultdict(list)
# import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
mod = 10**9 + 7


def readInts():
    return list(map(int, input().split()))


def main():
    S = eval(input())
    T = eval(input())
    dic_s = {}
    dic_t = {}
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if s in dic_t:
            if dic_t[s] != t:
                print("No")
                exit()
        if t in dic_s:
            if dic_s[t] != s:
                print("No")
                exit()
        dic_t[s] = t
        dic_s[t] = s
    print("Yes")


if __name__ == "__main__":
    main()

-# aa = collections.Counter(a) # list to list +# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] +# from collections import deque +# import collections.defaultdict(list) +# import bisect +# +#    d = m - k[i] - k[j] +#    if kk[bisect.bisect_right(kk,d) - 1] == d: +# +# +# +# pythonで無理なときは、pypyでやると正解するかも！！ +# +# -    # S: azzel -    # T: apple -    ok = True -        if s in list(dic_s.keys()): -            if dic_s[s] != t: -                ok = False -        if t in list(dic_t.keys()): -            if dic_t[t] != s: -                ok = False -        dic_s[s] = t -        dic_t[t] = s -        # print(dic_s,dic_t,sep='\n') -    if ok: -        print("Yes") -    else: -        print("No") +        if s in dic_t: +            if dic_t[s] != t: +                print("No") +                exit() +        if t in dic_s: +            if dic_s[t] != s: +                print("No") +                exit() +        dic_t[s] = t +        dic_s[t] = s +    print("Yes")