#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);}) #define rd_skip() while(*rp++>=48) #define wt(v) ({unsigned _z=v;do*--wp=_z%10+48;while(_z/=10);}) #define wt1(v) ({char wbuf[64],*wp=wbuf+sizeof wbuf;wt(v);write(1,wp,wbuf+sizeof wbuf-wp);}) #define rep(v,e) for(typeof(e) v=0;v=a?v:a) int h[10],d[10]; main(){ rd_init(); rd_skip(); while(*rp){ rd_skip(); h[rp[-2]-48]+=1; } int o=0; d[0]=200000; rep(i,10){ o+=h[i]/100; rep(j,h[i]%100){ int b[10]; rep(k,10){ b[k]=d[k]; } int l=i; rep(k,10){ chmax(d[l],b[k]+1); if(++l==10) l=0; } } } wt1(o*100+d[0]-200000); _exit(0); }