#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("inline") #include using namespace std; template struct cLtraits_identity{ using type = T; } ; template using cLtraits_try_make_signed = typename conditional< is_integral::value, make_signed, cLtraits_identity >::type; template struct cLtraits_common_type{ using tS = typename cLtraits_try_make_signed::type; using tT = typename cLtraits_try_make_signed::type; using type = typename common_type::type; } ; template inline auto max_L(S a, T b) -> typename cLtraits_common_type::type{ return (typename cLtraits_common_type::type) a >= (typename cLtraits_common_type::type) b ? a : b; } inline int my_getchar_unlocked(){ static char buf[1048576]; static int s = 1048576; static int e = 1048576; if(s == e && e == 1048576){ e = fread_unlocked(buf, 1, 1048576, stdin); s = 0; } if(s == e){ return EOF; } return buf[s++]; } inline void rd(char &c){ int i; for(;;){ i = my_getchar_unlocked(); if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){ break; } } c = i; } inline int rd(char c[]){ int i; int sz = 0; for(;;){ i = my_getchar_unlocked(); if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){ break; } } c[sz++] = i; for(;;){ i = my_getchar_unlocked(); if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){ break; } c[sz++] = i; } c[sz]='\0'; return sz; } struct MY_WRITER{ char buf[1048576]; int s; int e; MY_WRITER(){ s = 0; e = 1048576; } ~MY_WRITER(){ if(s){ fwrite_unlocked(buf, 1, s, stdout); } } } ; MY_WRITER MY_WRITER_VAR; void my_putchar_unlocked(int a){ if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){ fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout); MY_WRITER_VAR.s = 0; } MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a; } inline void wt_L(char a){ my_putchar_unlocked(a); } inline void wt_L(int x){ int s=0; int m=0; char f[10]; if(x<0){ m=1; x=-x; } while(x){ f[s++]=x%10; x/=10; } if(!s){ f[s++]=0; } if(m){ my_putchar_unlocked('-'); } while(s--){ my_putchar_unlocked(f[s]+'0'); } } int main(){ int N; char S[100000]; int sz = 0; int d[100000]; int cnt[8] = {}; int i; int j; int k; int ress = 0; int res[100000]; N = rd(S); for(i=(N)-1;i>=(0);i--){ int Q5VJL1cS; k = S[i] - 'A' + 10; for(Q5VJL1cS=(0);Q5VJL1cS<(4);Q5VJL1cS++){ d[sz++] = k % 2; k /= 2; } } while(sz%3){ d[sz++] = 0; } for(i=(0);i<(sz);i+=(3)){ k = d[i] + d[i+1] * 2 + d[i+2] * 4; cnt[k]++; } int t_ynMSdg; cLtraits_try_make_signed::type>::type KrdatlYV; if(8==0){ KrdatlYV = 0; } else{ KrdatlYV = cnt[0]; for(t_ynMSdg=(1);t_ynMSdg<(8);t_ynMSdg++){ KrdatlYV = max_L(KrdatlYV, cnt[t_ynMSdg]); } } k =KrdatlYV; for(i=(0);i<(8);i++){ if(k==cnt[i]){ res[ress++] = i; } } { int V9aVTaxx; if(ress==0){ wt_L('\n'); } else{ for(V9aVTaxx=(0);V9aVTaxx<(ress-1);V9aVTaxx++){ wt_L(res[V9aVTaxx]); wt_L(' '); } wt_L(res[V9aVTaxx]); wt_L('\n'); } } return 0; } // cLay version 20211024-1 // --- original code --- // int N; char S[1d5]; // int sz = 0, d[], cnt[8] = {}, i, j, k; // int ress = 0, res[]; // rd(S@N); // rrep(i,N){ // k = S[i] - 'A' + 10; // rep(4) d[sz++] = k % 2, k /= 2; // } // while(sz%3) d[sz++] = 0; // rep(i,0,sz,3){ // k = d[i] + d[i+1] * 2 + d[i+2] * 4; // cnt[k]++; // } // k = max(cnt(8)); // rep(i,8) if(k==cnt[i]) res[ress++] = i; // wt(res(ress));