#include using namespace std; #define REP(i,n) for(ll i=0; i<(ll)(n); i++) #define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++) #define pb push_back #define INF 1000000007LL #define all(a) (a).begin(),(a).end() typedef long long ll; typedef pair p; int dy[4]={-1,1,0,0}; int dx[4]={0,0,1,-1}; int a=191,b=3; ll mod_pow(ll n, ll m, int modulo){ if (m==1) return n; ll tmp = mod_pow(n,m/2,modulo); tmp*=tmp; tmp%=modulo; if (m%2==0) return tmp; tmp*=n; tmp%=modulo; return tmp; } string s; int alpha[26]; int main(){ ios::sync_with_stdio(false); cin >> s; REP(i,s.length()) alpha[s[i]-'A']++; int ans_a=1,ans_b=1; FOR(i,2,s.length()+1){ ans_a*=i;ans_a%=a; ans_b*=i;ans_b%=b; } REP(i,26){ int tmp_a=1,tmp_b=1; FOR(j,2,alpha[i]+1){ tmp_a*=j;tmp_a%=a; tmp_b*=j;tmp_b%=b; } if(ans_a==tmp_a) ans_a=1; else ans_a*=mod_pow(tmp_a, a-2, a);ans_a%=a; if(ans_b==tmp_b) ans_b=1; else ans_b*=tmp_b;ans_b%=b; } ans_a+=a-1;ans_a%=a; ans_b+=b-1;ans_b%=b; map ans; REP(i,a){ ans[ans_b+i*b]++; } REP(i,b) if(ans[ans_a+i*a]) cout << ans_a+i*a << endl; return 0; }