string = 'abcdcdc'
sub_string = 'cdc'
idx = 0
count_p = 0
count = 0
for i in list(string):
if i in sub_string[idx]:
count += 1
idx += 1
if idx == 2:
idx = 0
elif count == 3:
count = 0 if i != 'c' else 1
count_p += 1
else:
count = 0
print(count_p)
c3RyaW5nID0gJ2FiY2RjZGMnCnN1Yl9zdHJpbmcgPSAnY2RjJwoKaWR4ID0gMApjb3VudF9wID0gMApjb3VudCA9IDAKZm9yIGkgaW4gbGlzdChzdHJpbmcpOgogICAgaWYgaSBpbiBzdWJfc3RyaW5nW2lkeF06CiAgICAgICAgY291bnQgKz0gMQogICAgICAgIGlkeCArPSAxCiAgICAgICAgaWYgaWR4ID09IDI6CiAgICAgICAgICAgIGlkeCA9IDAKICAgICAgICBlbGlmIGNvdW50ID09IDM6CiAgICAgICAgICAgIGNvdW50ID0gMCBpZiBpICE9ICdjJyBlbHNlIDEKICAgICAgICAgICAgY291bnRfcCArPSAxCgogICAgZWxzZToKICAgICAgICBjb3VudCA9IDAKICAgICAgICAKCnByaW50KGNvdW50X3Ap