import sys



def o(c): return ord(c) - ord('a')



s, t = sys.stdin.read().split()



def main():

    g1 = [set() for _ in range(26)]

    g2 = [set() for _ in range(26)]

    for i in range(len(s)):

        a = o(s[i]); b = o(t[i])

        g1[a].add(b); g2[b].add(a)



    for i in range(26):

        if len(g1[i]) >= 2 or len(g2[i]) >= 2:

            print('No')

            return

    print('Yes')



if __name__ ==  '__main__':

    main()
import sys

from string import ascii_lowercase



o = dict(list(zip(ascii_lowercase, list(range(26)))))



s, t = sys.stdin.read().split()



def main():

    g1 = [set() for _ in range(26)]

    g2 = [set() for _ in range(26)]

    for i in range(len(s)):

        a = o[s[i]]; b = o[t[i]]

        g1[a].add(b); g2[b].add(a)



    for i in range(26):

        if len(g1[i]) >= 2 or len(g2[i]) >= 2:

            print('No')

            return

    print('Yes')



if __name__ ==  '__main__':

    main()
import sys


def o(c):
    return ord(c) - ord("a")


s, t = sys.stdin.read().split()


def main():
    g1 = [set() for _ in range(26)]
    g2 = [set() for _ in range(26)]
    for i in range(len(s)):
        a = o(s[i])
        b = o(t[i])
        g1[a].add(b)
        g2[b].add(a)
    for i in range(26):
        if len(g1[i]) >= 2 or len(g2[i]) >= 2:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

import sys
from string import ascii_lowercase

o = dict(list(zip(ascii_lowercase, list(range(26)))))
s, t = sys.stdin.read().split()


def main():
    g1 = [set() for _ in range(26)]
    g2 = [set() for _ in range(26)]
    for i in range(len(s)):
        a = o[s[i]]
        b = o[t[i]]
        g1[a].add(b)
        g2[b].add(a)
    for i in range(26):
        if len(g1[i]) >= 2 or len(g2[i]) >= 2:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

+from string import ascii_lowercase - -def o(c): -    return ord(c) - ord("a") - - +o = dict(list(zip(ascii_lowercase, list(range(26))))) -        a = o(s[i]) -        b = o(t[i]) +        a = o[s[i]] +        b = o[t[i]]