// // main.cpp // Q414 // // Created by AkihiroKOBAYASHI on 7/23/15. // Copyright (c) 2015 Akhr5884. All rights reserved. // #include #include int bunshi[1000] = {0}; int bunbo[1000] = {0}; int count = 0; void factorial(int n, int flag) { if(n > 1) { if(flag == 1) { // bunshi bunshi[count] = n; count++; factorial(n-1, 1); } else if(flag == 0) { // bunbo bunbo[count] = n; count++; factorial(n-1, 0); } } // if (n > 0) { // return n * factorial(n - 1); // } else { // return 1; // } } int judge() { while(1) { if(bunbo[count] == 0) { break; } for(int i = 0; bunshi[i] != 0; i++) { if(bunshi[i]%bunbo[count] == 0) { bunshi[i] = bunshi[i]/bunbo[count]; break; } } count++; } count = 0; int aaa = 1; for(int i = 0; bunshi[i] != 0; i++) { if(bunshi[i] != 0) { aaa*=bunshi[i]; aaa = aaa%573; if(aaa%573==0) { aaa = 573; } } } return aaa-1; } int main(int argc, const char * argv[]) { std::string s; int flag[1000] = {0}; int now; bunbo[0] = 1; std::cin >> s; const char *chr = s.c_str(); for(int i = 0; i < s.length(); i++) { flag[i] = 1; } for(int i = 0; i < s.length()-1; i++) { now = 1; for(int j = i; j < s.length()-1; j++) { if(chr[i] == chr[j+1] && flag[j+1] == 1) { flag[j+1] = 0; now++; } } factorial(now, 0); } count = 0; factorial((int)s.length(), 1); count = 0; std::cout << judge() << "\n"; return 0; }