from itertools import permutations S = list(input()) h = S[0] e = S[-1] ans = set() for i in permutations(S): if i[0] == h or i[0] == e: ans.add(i) print(len(ans))