program main implicit none integer*8::N integer*8::upper,lower,len,head,num=0,i character*19::S character*10::uf='(i0)' character*10::lf='(i9)' read *,S len = LEN_TRIM(S) if(len.le.9) then print '("0")' return end if write(uf(3:3),'(i0)'), len-9 read (S(1:1),'(i1)') head read (S,uf), upper read (S(len-8:len),lf), lower do i=0,len-10 num = num+head*10**i end do if (lower.ge.num) then print '(i0)', (len-10)*9+head-1+(head/num) else print '(i0)', (len-10)*9+head-1 end if contains subroutine aprinter(array) integer*8::array(:) character*32::cformat='(i0, (1x,i0))' write(cformat(5:9),'(i0)'),size(array) write(*,cformat) array end subroutine aprinter end program main