#include #include #include #include #include #include #include using namespace std; long long factorial(int n) { int ret = 1; for(int k = 1; k <= n; k++) { ret *= k; } return ret; } int main() { string in; cin >> in; string s = ""; int count[8] = {0}; for (int i = 0;i < (int)in.length();i++){ string p = in.substr(i,1); unsigned int loc = (int)s.find(p); if (loc == string::npos){ s += p; count[s.length() -1]++; }else{ count[loc]++; } } long long pat; pat = factorial(in.length()); for (int i = 0;i < (int)s.length();i++){ pat /= factorial(count[i]); } pat--; cout << pat << endl; return 0; }