''''''(lambda a:print(abs(sum([list(reversed([ord(x)-64 for x in a[0]]))[x]*(26**x) for x in range(len(a[0]))])-sum([list(reversed([ord(x)-64 for x in a[1]]))[x]*(26**x) for x in range(len(a[1]))]))+1))(input().split())