# -*- coding: utf-8 -*-

import unittest





def func(s,t):

    n = len(s)

    for c in set(s):

        d = None

        for i in range(n):

            if s[i]==c:

                if d is None:

                    d = t[i]

                elif d!=t[i]:

                    return "No"

    for c in set(t):

        d = None

        for i in range(n):

            if t[i]==c:

                if d is None:

                    d = s[i]

                elif d!=s[i]:

                    return "No"

    return "Yes"



class Test(unittest.TestCase):

    def test(self):

        self.assertEqual(func("azzel", "apple"), "Yes")

        self.assertEqual(func("chokudai", "redcoder"), "No")

        self.assertEqual(func("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu"), "Yes")

        self.assertEqual(func("abc", "abc"), "Yes")



if __name__ == '__main__':

    s = eval(input())

    t = eval(input())

    # unittest.main()

    print((func(s,t)))

# -*- coding: utf-8 -*-

s = eval(input())

t = eval(input())

n = len(s)



ds = {}

dt = {}

for i in range(n):

    if s[i] not in ds:

        ds[s[i]] = t[i]

    elif ds[s[i]]!=t[i]:

        print("No")

        exit()

    if t[i] not in dt:

        dt[t[i]] = s[i]

    elif dt[t[i]]!=s[i]:

        print("No")

        exit()

print("Yes")

# -*- coding: utf-8 -*-
import unittest


def func(s, t):
    n = len(s)
    for c in set(s):
        d = None
        for i in range(n):
            if s[i] == c:
                if d is None:
                    d = t[i]
                elif d != t[i]:
                    return "No"
    for c in set(t):
        d = None
        for i in range(n):
            if t[i] == c:
                if d is None:
                    d = s[i]
                elif d != s[i]:
                    return "No"
    return "Yes"


class Test(unittest.TestCase):
    def test(self):
        self.assertEqual(func("azzel", "apple"), "Yes")
        self.assertEqual(func("chokudai", "redcoder"), "No")
        self.assertEqual(
            func("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu"), "Yes"
        )
        self.assertEqual(func("abc", "abc"), "Yes")


if __name__ == "__main__":
    s = eval(input())
    t = eval(input())
    # unittest.main()
    print((func(s, t)))

# -*- coding: utf-8 -*-
s = eval(input())
t = eval(input())
n = len(s)
ds = {}
dt = {}
for i in range(n):
    if s[i] not in ds:
        ds[s[i]] = t[i]
    elif ds[s[i]] != t[i]:
        print("No")
        exit()
    if t[i] not in dt:
        dt[t[i]] = s[i]
    elif dt[t[i]] != s[i]:
        print("No")
        exit()
print("Yes")

-import unittest - - -def func(s, t): -    n = len(s) -    for c in set(s): -        d = None -        for i in range(n): -            if s[i] == c: -                if d is None: -                    d = t[i] -                elif d != t[i]: -                    return "No" -    for c in set(t): -        d = None -        for i in range(n): -            if t[i] == c: -                if d is None: -                    d = s[i] -                elif d != s[i]: -                    return "No" -    return "Yes" - - -class Test(unittest.TestCase): -    def test(self): -        self.assertEqual(func("azzel", "apple"), "Yes") -        self.assertEqual(func("chokudai", "redcoder"), "No") -        self.assertEqual( -            func("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu"), "Yes" -        ) -        self.assertEqual(func("abc", "abc"), "Yes") - - -if __name__ == "__main__": -    s = eval(input()) -    t = eval(input()) -    # unittest.main() -    print((func(s, t))) +s = eval(input()) +t = eval(input()) +n = len(s) +ds = {} +dt = {} +for i in range(n): +    if s[i] not in ds: +        ds[s[i]] = t[i] +    elif ds[s[i]] != t[i]: +        print("No") +        exit() +    if t[i] not in dt: +        dt[t[i]] = s[i] +    elif dt[t[i]] != s[i]: +        print("No") +        exit() +print("Yes")