A=input() d={} for i in A: if i in d:d[i]+=1 else:d[i]=1 from math import factorial as f a=f(len(A)) for i in d:a//=f(d[i]) print((a-1)%573)