program main implicit none integer::G,C,P,i integer::gg,cc,pp data gg,cc,pp/3*0/ character*300::S read *,G,C,P,S do i=1,LEN_TRIM(S) if(S(i:i).eq.'G') then gg = gg + 1 else if(S(i:i).eq.'C') then cc = cc + 1 else pp = pp + 1 end if end do print '(i0)',3*(MIN(P,gg)+MIN(G,cc)+MIN(C,pp))+ & MIN(MAX(G-cc,0),MAX(gg-P,0))+ & MIN(MAX(C-pp,0),MAX(cc-G,0))+ & MIN(MAX(P-gg,0),MAX(pp-C,0)) end program main