S = [] for i in range(6): s = input() S.append(s) cnts = [0]*6 def solve(st): stnew = st while True: found = False m = len(st) l = list(st) for i in range(m): for j in range(m): x1 = l[i] x2 = l[j] x = (x1 + x2) % 10 if x not in stnew: found = True stnew.add(x) break if found == True: break if found == False: return len(stnew) return 0 for i in range(6): # i桁目 st = set() for j in range(6): st.add(int(S[j][i])) # print(st) cnts[i] = solve(st) ans = 1 for i in range(6): ans *= cnts[i] print(ans) # print(cnts)