import java.util.Scanner;
public class Main {

	public static void main(String[] args)throws Exception {
		Scanner stdIn=new Scanner(System.in);
		int a[]=new int[3000000];
		int b[]=new int[3000000];
		int c[]=new int[3000000];
		int d[]=new int[3000000];
		int e[]=new int[3000000];
		int f[]=new int[3000000];
		int g[]=new int[3000000];
		int h[]=new int[3000000];
		int i[]=new int[3000000];
		int j[]=new int[3000000];
		int k[]=new int[3000000];
		int l[]=new int[3000000];
		int m[]=new int[3000000];
		int n[]=new int[3000000];
		int o[]=new int[3000000];
		int p[]=new int[3000000];
		int q[]=new int[3000000];
		int r[]=new int[3000000];
		int s[]=new int[3000000];
		int t[]=new int[3000000];
		int u[]=new int[3000000];
		int v[]=new int[3000000];
		int w[]=new int[3000000];
		int x[]=new int[3000000];
		int y[]=new int[3000000];
		int z[]=new int[3000000];
		int A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0;
		String s1=stdIn.next();
		String t1=stdIn.next();
		String u1="0";
		int len=s1.length();
		int fin=0;
		char cha[]=new char[300000];
		char cha2[]=new char[300000];
		int INT=0,FIN=0;
		while(FIN<2) {
			while(INT<len) {
				cha[INT]=s1.charAt(INT);
				cha2[INT]=t1.charAt(INT);
				if(cha2[INT]=='a') {
					a[A]=INT;
					if(A>=1) 
						if(cha[a[A]]!=cha[a[A-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					A++;
				}
				if(cha2[INT]=='b') {
					b[B]=INT;
					if(B>=1) 
						if(cha[b[B]]!=cha[b[B-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					B++;
				}
				if(cha2[INT]=='c') {
					c[C]=INT;
					if(C>=1) 
						if(cha[c[C]]!=cha[c[C-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					C++;
				}
				if(cha2[INT]=='d') {
					d[D]=INT;
					if(D>=1) 
						if(cha[d[D]]!=cha[d[D-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					D++;
				}
				if(cha2[INT]=='e') {
					e[E]=INT;
					if(E>=1) 
						if(cha[e[E]]!=cha[e[E-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					E++;
				}
				if(cha2[INT]=='f') {
					f[F]=INT;
					if(F>=1) 
						if(cha[f[F]]!=cha[f[F-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					F++;
				}
				if(cha2[INT]=='g') {
					g[G]=INT;
					if(G>=1) 
						if(cha[g[G]]!=cha[g[G-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					G++;
				}
				if(cha2[INT]=='h') {
					h[H]=INT;
					if(H>=1) 
						if(cha[h[H]]!=cha[h[H-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					H++;
				}
				if(cha2[INT]=='i') {
					i[I]=INT;
					if(I>=1) 
						if(cha[i[I]]!=cha[i[I-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					I++;
				}
				if(cha2[INT]=='j') {
					j[J]=INT;
					if(J>=1) 
						if(cha[j[J]]!=cha[j[J-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					J++;
				}
				if(cha2[INT]=='k') {
					k[K]=INT;
					if(K>=1) 
						if(cha[k[K]]!=cha[k[K-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					K++;
				}
				if(cha2[INT]=='l') {
					l[L]=INT;
					if(L>=1) 
						if(cha[l[L]]!=cha[l[L-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					L++;
				}
				if(cha2[INT]=='m') {
					m[M]=INT;
					if(M>=1) 
						if(cha[m[M]]!=cha[m[M-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					M++;
				}
				if(cha2[INT]=='n') {
					n[N]=INT;
					if(N>=1) 
						if(cha[n[N]]!=cha[n[N-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					N++;
				}
				if(cha2[INT]=='o') {
					o[O]=INT;
					if(O>=1) 
						if(cha[o[O]]!=cha[o[O-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					O++;
				}
				if(cha2[INT]=='p') {
					p[P]=INT;
					if(P>=1) 
						if(cha[p[P]]!=cha[p[P-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					P++;
				}
				if(cha2[INT]=='q') {
					q[Q]=INT;
					if(Q>=1) 
						if(cha[q[Q]]!=cha[q[Q-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					Q++;
				}if(cha2[INT]=='r') {
					r[R]=INT;
					if(R>=1) 
						if(cha[r[R]]!=cha[r[R-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					R++;
				}
				if(cha2[INT]=='s') {
					s[S]=INT;
					if(S>=1) 
						if(cha[s[S]]!=cha[s[S-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					S++;
				}
				if(cha2[INT]=='t') {
					t[T]=INT;
					if(T>=1) 
						if(cha[t[T]]!=cha[t[T-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					T++;
				}
				if(cha2[INT]=='u') {
					u[U]=INT;
					if(U>=1) 
						if(cha[u[U]]!=cha[u[U-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					U++;
				}
				if(cha2[INT]=='v') {
					v[V]=INT;
					if(V>=1) 
						if(cha[v[V]]!=cha[v[V-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					V++;
				}
				if(cha2[INT]=='w') {
					w[W]=INT;
					if(W>=1) 
						if(cha[w[W]]!=cha[w[W-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					W++;
				}
				if(cha2[INT]=='x') {
					x[X]=INT;
					if(X>=1) 
						if(cha[x[X]]!=cha[x[X-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					X++;
				}
				if(cha2[INT]=='y') {
					y[Y]=INT;
					if(Y>=1) 
						if(cha[y[Y]]!=cha[y[Y-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					Y++;
				}
				if(cha2[INT]=='z') {
					z[Z]=INT;
					if(Z>=1) 
						if(cha[z[Z]]!=cha[z[Z-1]]) {
							System.out.println("No");
							fin=1;
							break;
						}
					Z++;
				}
				INT++;
			}u1=s1; s1=t1; t1=u1;INT=0;
		if(fin==1)
			break;
		A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;I=0;J=0;K=0;L=0;M=0;N=0;O=0;P=0;Q=0;R=0;S=0;T=0;U=0;V=0;W=0;X=0;Y=0;Z=0;
		FIN++;
		}
		if(fin==0)
			System.out.println("Yes");
	}
}

Measured memory_bytes: 374508