import bisect, collections, copy, heapq, itertools, math, string, sys

input = lambda: sys.stdin.readline().rstrip() 

sys.setrecursionlimit(10**7)

INF = float('inf')

def I(): return int(eval(input()))

def F(): return float(eval(input()))

def SS(): return eval(input())

def LI(): return [int(x) for x in input().split()]

def LI_(): return [int(x)-1 for x in input().split()]

def LF(): return [float(x) for x in input().split()]

def LSS(): return input().split()



def resolve():

    S = SS()

    T = SS()



    l = len(S)



    S_i = [[] for _ in range(26)]

    T_i = [[] for _ in range(26)]

    for i in range(l):

        S_i[ord(S[i]) - ord('a')].append(i)

        T_i[ord(T[i]) - ord('a')].append(i)



    S_set = set()

    T_set = set()

    for i in range(26):

        if S_i[i]: S_set.add(tuple(S_i[i]))

        if T_i[i]: T_set.add(tuple(T_i[i]))



    if S_set == T_set:

        print('Yes')

    else:

        print('No')



if __name__ == '__main__':

    resolve()

import bisect, collections, copy, heapq, itertools, math, string, sys

input = lambda: sys.stdin.readline().rstrip() 

sys.setrecursionlimit(10**7)

INF = float('inf')

def I(): return int(eval(input()))

def F(): return float(eval(input()))

def SS(): return eval(input())

def LI(): return [int(x) for x in input().split()]

def LI_(): return [int(x)-1 for x in input().split()]

def LF(): return [float(x) for x in input().split()]

def LSS(): return input().split()



def resolve():

    S = SS()

    T = SS()



    l = len(S)

    R0 = [-1] * 26

    R1 = [-1] * 26



    is_ok = True

    for i in range(l):

        S_num = ord(S[i]) - ord('a')

        T_num = ord(T[i]) - ord('a')

        # print(S_num, T_num)

        if R0[S_num] == -1:

            R0[S_num] = T_num

        else:

            if R0[S_num] != T_num:

                is_ok = False 

                break

        if R1[T_num] == -1:

            R1[T_num] = S_num

        else:

            if R1[T_num] != S_num:

                is_ok = False 

                break



    if is_ok:

        print('Yes')

    else:

        print('No')



if __name__ == '__main__':

    resolve()

import bisect, collections, copy, heapq, itertools, math, string, sys

input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float("inf")


def I():
    return int(eval(input()))


def F():
    return float(eval(input()))


def SS():
    return eval(input())


def LI():
    return [int(x) for x in input().split()]


def LI_():
    return [int(x) - 1 for x in input().split()]


def LF():
    return [float(x) for x in input().split()]


def LSS():
    return input().split()


def resolve():
    S = SS()
    T = SS()
    l = len(S)
    S_i = [[] for _ in range(26)]
    T_i = [[] for _ in range(26)]
    for i in range(l):
        S_i[ord(S[i]) - ord("a")].append(i)
        T_i[ord(T[i]) - ord("a")].append(i)
    S_set = set()
    T_set = set()
    for i in range(26):
        if S_i[i]:
            S_set.add(tuple(S_i[i]))
        if T_i[i]:
            T_set.add(tuple(T_i[i]))
    if S_set == T_set:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    resolve()

import bisect, collections, copy, heapq, itertools, math, string, sys

input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = float("inf")


def I():
    return int(eval(input()))


def F():
    return float(eval(input()))


def SS():
    return eval(input())


def LI():
    return [int(x) for x in input().split()]


def LI_():
    return [int(x) - 1 for x in input().split()]


def LF():
    return [float(x) for x in input().split()]


def LSS():
    return input().split()


def resolve():
    S = SS()
    T = SS()
    l = len(S)
    R0 = [-1] * 26
    R1 = [-1] * 26
    is_ok = True
    for i in range(l):
        S_num = ord(S[i]) - ord("a")
        T_num = ord(T[i]) - ord("a")
        # print(S_num, T_num)
        if R0[S_num] == -1:
            R0[S_num] = T_num
        else:
            if R0[S_num] != T_num:
                is_ok = False
                break
        if R1[T_num] == -1:
            R1[T_num] = S_num
        else:
            if R1[T_num] != S_num:
                is_ok = False
                break
    if is_ok:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    resolve()

-    S_i = [[] for _ in range(26)] -    T_i = [[] for _ in range(26)] +    R0 = [-1] * 26 +    R1 = [-1] * 26 +    is_ok = True -        S_i[ord(S[i]) - ord("a")].append(i) -        T_i[ord(T[i]) - ord("a")].append(i) -    S_set = set() -    T_set = set() -    for i in range(26): -        if S_i[i]: -            S_set.add(tuple(S_i[i])) -        if T_i[i]: -            T_set.add(tuple(T_i[i])) -    if S_set == T_set: +        S_num = ord(S[i]) - ord("a") +        T_num = ord(T[i]) - ord("a") +        # print(S_num, T_num) +        if R0[S_num] == -1: +            R0[S_num] = T_num +        else: +            if R0[S_num] != T_num: +                is_ok = False +                break +        if R1[T_num] == -1: +            R1[T_num] = S_num +        else: +            if R1[T_num] != S_num: +                is_ok = False +                break +    if is_ok: