from itertools import product, combinations

mini = 12
maxi = 82

table_i = (i for i in range(mini, maxi+1))

table = list(product(table_i, repeat=4))

solution = list()
for item in table:
    if str(item[0]+item[1]+item[2]+item[3]) == str(item[0]+item[1]+item[2]+item[3])[::-1] and str(item[0]*item[1]*item[2]*item[3]) == str(item[0]*item[1]*item[2]*item[3])[::-1]:
        if sorted(item) not in solution:
            solution.append(sorted(item))

print(len(solution))
