// Wrongri-La Shower #include #include typedef std::tuple T; typedef long long ll; // 573: 3 191 int count[26], inv[573]; int mod_pow(int a, int n){ int res = 1; while(n > 0){ if(n & 1){res = res * a % 573;} n >>= 1; a = a * a % 573; } return res; } int nCk(int n, int k){ if(n < k){return 0ll;} int n3 = 0, n191 = 0, other = 1; for(int i=n-k+1;i<=n;i++){ int x = i; while(x % 3 == 0){ ++n3; x /= 3; } while(x % 191 == 0){ ++n191; x /= 191; } other = other * x % 573; } int other2 = 1; for(int i=1;i<=k;i++){ int x = i; while(x % 3 == 0){ --n3; x /= 3; } while(x % 191 == 0){ --n191; x /= 191; } other2 = other2 * x % 573; } return mod_pow(3, n3) * mod_pow(191, n191) % 573 * other % 573 * inv[other2] % 573; } int main(){ for(int i=0;i<573;i++){ for(int j=0;j<573;j++){ if(i * j % 573 == 1){inv[i] = j; break;} } } std::string S; std::cin >> S; for(char c : S){ count[c-'A'] += 1; } int res = 1ll; int sum = 0; for(int i=0;i<26;i++){ res = res * nCk(S.size()-sum, count[i]) % 573; sum += count[i]; } printf("%d\n", (res+573-1) % 573); }