Contest Solution!
\n\n# Code\n\nclass Solution:\n    def numberOfChild(self, n: int, k: int) -> int:\n        f=0\n        i=0\n        while True:\n            if k==0:\n       
\n\n# Code\n```\nclass Solution:\n    def numberOfChild(self, n: int, k: int) -> int:\n        f=0\n        i=0\n        while True:\n            if k==0:\n                return i\n            if f==0:\n                i+=1\n                if i==n-1:\n                    f=1\n            elif f==1:\n                i-=1\n                if i==0:\n                    f=0\n            k-=1\n```
['Python3']