program main implicit none character*8::S integer*8::c(26),fact(8) integer*8::i,indx,total data c/26*0/,fact/1,2,6,24,120,720,5040,40320/ read *,S do i=1,LEN_TRIM(S) indx = ICHAR(S(i:i))-ICHAR('A')+1 c(indx) = c(indx) + 1 end do total = fact(LEN_TRIM(S)) do i=1,26 if(c(i).gt.1) then total = total/fact(c(indx)) end if end do print '(i0)',total -1 end program main