Piyush and magical park

pls check the code .
it is giving 11 as answer for given test case