Just output the current number of found ones + 1. Clearly, we will guess correctly for i = last\_one, where last\_one is the position of the last one in the string.

That is Ok but there should be somthing to understand … What is the value of K … Give more details …

K is the value of 1’s in the binary string S.
It is assumed that there is atleast one ‘1’ in binary string S ,
So that’s why K>=1