program main implicit none integer::N,i,j,M character*14::a integer::days(-13:28) integer::days2(-13:28) data days/42*0/ read *,N read *,a(1:7),a(8:14) do i=1,14 if(a(i:i).eq.'o') days(i) = 1 end do M = 0 do i=-13,15 if(days(i).eq.0) continue days2 = days do j=i,i+N-1 if(days(j).eq.1) exit days2(j) = 1 end do M = MAX(M,get_longest(days2)) end do print '(i0)', M contains function get_longest(days2) result(L) integer::days2(-13:27),L,M integer::i L = 0 M = 0 do i=-13,28 if(days2(i).eq.1) then M = M + 1 else L = MAX(L,M) M = 0 end if end do L = MAX(L,M) end function get_longest end program main