#include using namespace std; #define MD 1000003 int S[26]; char T[1000010]; int xlen[1000010]; int xnnn[1000010]; int inv[1000010]; int get_inv(long long a, int md){ long long e, s=md, t=a, u=1, v=0; while(s){ e=t/s; t-=e*s; u-=e*v; swap(t,s); swap(u,v); } if(u<0){ u+=md; } return u; } void mkinv(){ for(int i=1;i>S[c]; } cin>>T; int tlen=strlen(T); int r=1; for(int c=0;c<26;++c){ priority_queue> pq; int n=0; int st=-1; for(int i=0;i<=tlen;++i){ if(T[i]==c+'a'){ if(st<0){ st=i; } }else{ if(st>=0){ int xl=i-st; xlen[n]=xl; xnnn[n]=xl; pq.push(make_pair(1.*(xl+1),n)); ++n; if((S[c]-=xl)<0){ cout<<0; exit(0); } st=-1; } } } if(n) while(S[c]--){ auto p=pq.top();pq.pop(); n=p.second; ++xnnn[n]; pq.push(make_pair(1.*(xnnn[n]+1)/(xnnn[n]+1-xlen[n]),n)); r=(long long)r*xnnn[n]%MD; r=(long long)r*inv[xnnn[n]-xlen[n]]%MD; if(r==0){ cout<<0; exit(0); } } } cout<