from itertools import product
res = sum(1 for v in product('НАСТЯ', repeat=6) if v.count('А') < 2 and v.count('Я') < 2)
print(res)