Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(200000)


s = input()
num = len(s)
ans = 0

def count(pos, befor, co):
  global ans
  if pos >= num:
    if ans < co:
      ans = co
    return True
  
  for p in range(1, 3):
    if ans > co + len(s[pos+p:]) + 1:
      break
    if s[pos:pos+p] != befor:
      a = count(pos + p, s[pos:pos+p], co+1)
      
        

  return True

ans = 0

a = count(0, "", 0)
print(ans)


Fixed submission:
s = input()
num = len(s)
ans = 0
pos = 0
 
while True:
  c = s[pos]
  count = 0
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
          pos += count
          count = 0
          
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1
 
    break
 
 
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)


s = input()
num = len(s)
ans = 0

def count(pos, befor, co):
  global ans
  if pos >= num:
    if ans < co:
      ans = co
    return True
  
  for p in range(1, 3):
    if ans > co + len(s[pos+p:]) + 1:
      break
    if s[pos:pos+p] != befor:
      a = count(pos + p, s[pos:pos+p], co+1)
      
        

  return True

ans = 0

a = count(0, "", 0)
print(ans)


Fixed submission:
s = input()
num = len(s)
ans = 0
pos = 0
 
while True:
  c = s[pos]
  count = 0
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
          pos += count
          count = 0
          
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1
 
    break
 
 
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10000)


s = input()
num = len(s)
ans = 0

def count(pos, befor, co):
  global ans
  if pos >= num:
    if ans < co:
      ans = co
    return True
  
  for p in range(1, num-pos+1):
    if ans > co + len(s[pos+p:]) + 1:
      break
    if s[pos:pos+p] != befor:
      a = count(pos + p, s[pos:pos+p], co+1)
      break
        

  return True

ans = 0

a = count(0, "", 0)
print(ans)


Fixed submission:
s = input()
num = len(s)
ans = 0
pos = 0
 
while True:
  c = s[pos]
  count = 0
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
          pos += count
          count = 0
          
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1
 
    break
 
 
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
num = len(s)
ans = 0

def count(pos, befor, co):
  global ans
  if pos >= num:
    if ans < co:
      ans = co
    return True
  
  for p in range(1, num-pos+1):
    if ans > co + len(s[pos+p:]) + 1:
      break
    if s[pos:pos+p] != befor:
      a = count(pos + p, s[pos:pos+p], co+1)
        

  return True

ans = 0

a = count(0, "", 0)
print(ans)


Fixed submission:
s = input()
num = len(s)
ans = 0
pos = 0
 
while True:
  c = s[pos]
  count = 0
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
          pos += count
          count = 0
          
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1
 
    break
 
 
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
num = len(s)
ans = 0

def count(pos, befor, co):
  global ans
  if pos >= num:
    if ans < co:
      ans = co
    return True
  
  for p in range(1, num-pos+1):
    if s[pos:pos+p] != befor:
      a = count(pos + p, s[pos:pos+p], co+1)
        

  return True

ans = 0

a = count(0, "", 0)
print(ans)


Fixed submission:
s = input()
num = len(s)
ans = 0
pos = 0
 
while True:
  c = s[pos]
  count = 0
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
          pos += count
          count = 0
          
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1
 
    break
 
 
print(ans)

Buggy python submission (verdict: Runtime Error):
s = input()
num = len(s)
ans = 0

def count(pos, befor):
  co = 0
  if pos >= num:
    ans = 12
    #print(li, len(li))
    return 1
  
  for p in range(1, num-pos+1):
    if s[pos:pos+p] != befor:
      a = count(pos + p, s[pos:pos+p])
      if a and a > co:
        co = a
        

  return co + 1

ans = count(0, "")
print(ans - 1)


Fixed submission:
s = input()
num = len(s)
ans = 0
pos = 0
 
while True:
  c = s[pos]
  count = 0
  for i in range(num - pos):
    if s[pos + i] == c:
      count += 1
    else:
      ans += (count//3)*2  
      if i < num:
        if count % 3 == 1:
          ans += 1
        elif count % 3 == 2:
          ans += 2
          pos += 1
          pos += count
          count = 0
          
      break
  pos += count
  
  if pos >= num:
    ans += (count // 3) * 2 
    if count % 3 != 0:
      ans += 1
 
    break
 
 
print(ans)