import math from collections import Counter s = input().strip() count = Counter(s) n = len(s) total = math.factorial(n) for c in count.values(): total //= math.factorial(c) ans = total - 1 print(ans)