#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<iomanip>
#include<queue>
#include<string>

typedef long long ll;
const int inf = 0x3f3f3f3f,maxn = 200000 + 5;

using namespace std;

int main(){

	char s[maxn],t[maxn];

	while(cin >> s >> t)
	{

		int book[30];
		memset(book,-1,sizeof(book));

		int len = strlen(s);
		bool flag = false;

		for(int i = 0;i < len;i++)
		{

			if(book[s[i] - 'a'] == -1)
			{

				book[s[i] - 'a'] = t[i] - 'a';

			}

			else if(book[s[i] - 'a'] != t[i] - 'a')
			{
				puts("No");
				flag = true;
				break;
			}

		}


		if(!flag)
		{
			memset(book,-1,sizeof(book));
			for(int i = 0;i < len;i++)
			{
				if(book[t[i] - 'a'] == -1)
				{
					book[t[i] - 'a'] = s[i] - 'a';
				}

				else if(book[t[i] - 'a'] != s[i] - 'a')
				{
					puts("No");
					flag = true;
					break;
				}
			}
		}

		if(!flag) puts("Yes");

	}

	return 0;
}