import java.math.BigInteger; import java.util.Arrays; import java.util.LinkedList; import java.util.Scanner; public class Main { public static final int SIZE = 26; public static BigInteger fact(int b){ BigInteger ret = BigInteger.ONE; for(int i = 1; i <= b; i++){ ret = ret.multiply(BigInteger.valueOf(i)); } return ret; } /* 573 = 3 * 191 なので, mod 3 と mod 191 の結果から, mod 573 の結果を中国剰余定理で合成すればいい. */ public static void main(String[] args){ Scanner sc = new Scanner(System.in); final char[] inputs = sc.next().toCharArray(); int[] counter = new int[SIZE]; for(final char c : inputs){ counter[c - 'A']++; } BigInteger answer = fact(inputs.length); for(int i = 0; i < SIZE; i++){ if(counter[i] == 0){ continue; } answer = answer.divide(fact(counter[i])); } answer = answer.subtract(BigInteger.ONE); System.out.println(answer.mod(BigInteger.valueOf(573))); } }