"""
问题:输入一个只含1、0的字符串,要求通过把1改成0,
使得最后字符串的子窜不含‘101’,求最少多少次可以实现
"""
def test():
"""
方案解决函数
"""
s = input() # 输入一个字符串
L = list(s) # 转化为列表
print("第0次:\t" + "".join(L))
r = s
index = r.find('101') # 从左到右寻找第一个101
count = 0 # 设置计数器
while index != -1: # 只要有就继续循环
L[index + 2] = '0' # 将1换成0
r = "".join(L)
index = r.find('101', index) # 寻找下一个101子串
count = count + 1 # 计数
print(f'第{count}次:\t{r}')
print(f'共需要变换{count}次')
if __name__ == '__main__':
end = ''
while True:
test()
if end == 'end':
break