integer::N,K,i,b=0 integer,allocatable,dimension(:)::a character(10000)::S character,allocatable,dimension(:)::Sm read *,N,K allocate(Sm(N),a(N)) read *,S do i=1,N Sm(i)=S(i:i) if(Sm(i)=='(') then a(i)=1 else a(i)=-1 end if end do if(Sm(K)=='(') then do i=K,N b=b+a(i) if(b==0) then print *,i end if end do else do i=K,0,-1 b=b+a(i) if(b==0) then print *,i end if end do end if end