import sys def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) S = S() N = len(S) count = [0]*26 for s in S: count[ord(s)-65] += 1 def order(n,p): res = 0 while n % p == 0: res += 1 n //= p return res,n order3,order191 = 0,0 mod3,mod191 = 1,1 for i in range(1,N+1): e3,f3 = order(i,3) e191,f191 = order(i,191) order3 += e3 mod3 *= f3 mod3 %= 3 order191 += e191 mod191 *= f191 mod191 %= 191 for c in count: for i in range(1,c+1): e3,f3 = order(i,3) e191,f191 = order(i,191) order3 -= e3 mod3 *= f3 mod3 %= 3 order191 -= e191 mod191 *= pow(f191,189,191) mod191 %= 191 if order3: mod3 = 0 if order191: mod191 = 0 def ext_gcd(a,b): # a*x+b*y == gcd(a,b) たる gcd(a,b),x,y if b > 0: d,x,y = ext_gcd(b,a % b) return d,y,x-(a//b)*y return a,1,0 def remainder(V): # Z == Xi (mod Yi) たる Z, lcm(Yi) x,lcm = 0,1 for X,Y in V: g,a,b = ext_gcd(lcm,Y) x,lcm = (Y*b*x+lcm*a*X)//g,lcm*(Y//g) x %= lcm return x,lcm ans,l = remainder([(mod3,3),(mod191,191)]) ans -= 1 ans %= 573 print(ans)