from itertools import * A = [] for i in range(6): L = [int(a) for a in list(input())] A.append(L) def f(L, x): LL = [0] * 6 for i in range(6): LL[i] = L[i] * x LL[i] %= 10 return L ans = set() for t in product(range(10), repeat=6): temp = [0] * 6 for i in range(6): # g = f(A[i], t[i]) for j in range(6): temp[j] += A[i][j] * t[i] temp[j] %= 10 for i in range(6): temp[i] = str(temp[i]) ans.add("".join(temp)) print(len(ans))