#include using namespace std; const int mod = 1e9; int memo[1010][1010]; int C(int n, int k) { if (memo[n][k] != -1) return memo[n][k]; if (n == 0) { return 1; } int ret = 0; if (k > 0) ret += C(n - 1, k - 1); if (k < n) ret += C(n - 1, k); return memo[n][k] = ret % mod; } int main() { string S; cin >> S; map mp; for (auto& c : S) { mp[c]++; } for (int i = 0; i < 1001; i++) { for (int j = 0; j < 1001; j++) { memo[i][j] = -1; } } int ans = 1; int res = S.size(); for (auto& p : mp) { (ans *= C(res, p.second)) %= mod; res -= p.second; } ((ans += mod) -= 1) %= mod; cout << ans << endl; }