N, M = map(int, input().split())
A, B = input().split()
alp = [3,2,1,2,4,3,1,3,1,1,3,1,3,2,1,2,2,2,1,2,1,1,1,2,2,1]
AB = ""
min_str = min(N,M)
for i in range(min_str): AB += A[i]+B[i]
AB+=A[min_str:]+B[min_str:]
num_lst=[alp[ord(i)-ord('A')] for i in AB]
for i in range(N+M-2):
for j in range(len(num_lst)-1-i):
num_lst[j] += num_lst[j+1]
print("{}%".format(num_lst[0] % 10*10 + num_lst[1]%10))