import math tmp = raw_input() ans = math.factorial(len(tmp)) hist = [0] * 26 for s in tmp: hist[ord(s) - ord("A")] += 1 for i in hist: ans /= math.factorial(i) print (ans - 1) % 573