from collections import Counter from math import factorial from sys import stdin, stdout input = lambda: stdin.readline().rstrip() write = stdout.write def main(): S = input() n1, n2 = factorial(len(S)), 1 cnt = Counter(S) for i in cnt.values(): n2 *= factorial(i) ans = (n1 // n2) % 573 - 1 print(ans) main()