using System; using System.Collections.Generic; using System.Linq; namespace No171_1{ public class Program{ public static void Main(string[] args){ const int mod = 573; var str = Console.ReadLine(); var length = str.Length; var charCount = new int[26]; var facSeq = Enumerable.Range(1, length).ToArray(); foreach(var s in str){ charCount[s - 'A']++; } Func> func = n =>{ var tmp = n; var list = new List(); for(var i = 2; i * i <= tmp; i++){ while(tmp % i == 0){ tmp /= i; list.Add(i); } } if(tmp > 1) list.Add(tmp); return list; }; foreach(var cc in charCount){ for(var i = 2; i <= cc; i++){ foreach(var j in func(i)){ for(var k = 0; k < length; k++) { if(facSeq[k] % j == 0) { facSeq[k] /= j; break; } } } } } var result = 1; foreach(var fac in facSeq){ result *= fac; result %= mod; } Console.WriteLine(result == 0 ? mod - 1 : result - 1); Console.ReadLine(); } } }