import sys



input = sys.stdin.readline





def main():

    S = input().rstrip()

    T = input().rstrip()



    S_table = {}

    T_table = {}

    ans = "Yes"

    for s, t in zip(S, T):

        # S

        if s in S_table:

            if S_table[s] != t:

                ans = "No"

        else:

            S_table[s] = t

        # T

        if t in T_table:

            if T_table[t] != s:

                ans = "No"

        else:

            T_table[t] = s



    print(ans)





if __name__ == "__main__":

    main()

import sys

from collections import Counter



input = sys.stdin.readline





def main():

    S = input().rstrip()

    T = input().rstrip()



    c_S = Counter(S)

    c_T = Counter(T)

    count_S = list(c_S.values())

    count_T = list(c_T.values())

    count_S.sort()

    count_T.sort()

    is_same = True

    for s, t in zip(count_S, count_T):

        if s != t:

            is_same = False

            break



    ans = "Yes" if is_same else "No"

    print(ans)





if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline


def main():
    S = input().rstrip()
    T = input().rstrip()
    S_table = {}
    T_table = {}
    ans = "Yes"
    for s, t in zip(S, T):
        # S
        if s in S_table:
            if S_table[s] != t:
                ans = "No"
        else:
            S_table[s] = t
        # T
        if t in T_table:
            if T_table[t] != s:
                ans = "No"
        else:
            T_table[t] = s
    print(ans)


if __name__ == "__main__":
    main()

import sys
from collections import Counter

input = sys.stdin.readline


def main():
    S = input().rstrip()
    T = input().rstrip()
    c_S = Counter(S)
    c_T = Counter(T)
    count_S = list(c_S.values())
    count_T = list(c_T.values())
    count_S.sort()
    count_T.sort()
    is_same = True
    for s, t in zip(count_S, count_T):
        if s != t:
            is_same = False
            break
    ans = "Yes" if is_same else "No"
    print(ans)


if __name__ == "__main__":
    main()

+from collections import Counter -    S_table = {} -    T_table = {} -    ans = "Yes" -    for s, t in zip(S, T): -        # S -        if s in S_table: -            if S_table[s] != t: -                ans = "No" -        else: -            S_table[s] = t -        # T -        if t in T_table: -            if T_table[t] != s: -                ans = "No" -        else: -            T_table[t] = s +    c_S = Counter(S) +    c_T = Counter(T) +    count_S = list(c_S.values()) +    count_T = list(c_T.values()) +    count_S.sort() +    count_T.sort() +    is_same = True +    for s, t in zip(count_S, count_T): +        if s != t: +            is_same = False +            break +    ans = "Yes" if is_same else "No"