#include #include #include #include #include #include #include using namespace std; const int MOD = 573; int main() { string s; cin >> s; vector alpha(26, 0); int n = s.size(); char c; for (int i = 0; i < n; i++) { alpha[s[i] - 'A']++; } int exist = 0; for (int i = 0; i < alpha.size(); i++) { if (alpha[i] > 0) { exist++; } } if (exist == 1) { cout << 0 << endl; return 0; } list product; for (int i = 2; i <= n; i++) { product.push_back(i); } list devide; for (int i = 0; i < alpha.size(); i++) { for (int j = alpha[i]; j > 1; j--) { devide.push_back(j); } } devide.sort(greater()); for (auto itd = devide.begin(); itd != devide.end(); itd++) { for(auto itp = product.begin(); itp != product.end(); itp++) { if (*itp == *itd) { product.erase(itp); break; } else if (*itp %= *itd) { *itp /= *itd; product.sort(); break; } } } int ans = 1; for(auto itp = product.begin(); itp != product.end(); itp++) { ans = (ans * *itp) % MOD; } ans = (ans + MOD - 1) % MOD; cout << ans << endl; return 0; }