#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) int main() { ios_base::sync_with_stdio(0); cin.tie(0); string s; cin >> s; string t = s; sort(t.begin(), t.end()); int ret = 0; do { if (t != s) ++ret; } while (next_permutation(t.begin(), t.end())); cout << ret << endl; return 0; }