import math a=input() b=input() n=0 for i in range(len(a)): j=b.find(a[i]) try: if a[i+1]==b[j-1]: n+=1 except: pass print(int(math.pow(2,n)))