output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      s
attempt: # -*- coding: utf-8 -*-
  from copy import deepcopy
  import re
  
  result = 0
  
  
  N = int(input())
  s = input() + "0"
  
  # text = s.replace("10", "a").replace("a0", "100")
  text = s
  ts = text.split("00")
  if len(ts) > 1:
      for i in range(1, len(ts)):
          ts[i] = "0" + ts[i]
      for i in range(len(ts) - 1):
          ts[i] = ts[i] + "0"
  
  for t in ts:
      tmpa = 0
      tmpb = 0
  
      A = (t.replace("10", "a") + "0").replace("a0", "100")
      B = (t[::-1].replace("10", "a") + "0").replace("a0", "100")
      typea = re.findall("a1+", A)
      typeb = re.findall("a1+", B)
  
      for a in typea:
          tmpa += len(a) - 1
      tmpa += re.sub("a1+", "d", A).replace("aa", "b").count("b")
  
      for b in typeb:
          tmpb += len(b) - 1
      tmpb += re.sub("a1+", "d", B).replace("aa", "b").count("b")
      result += max(tmpa, tmpb)
  
  print(result)
  
problem_description: Statement
  
  N cells are arranged in a row. Some of them may contain tokens. You are given
  a string s that consists of `0`s and `1`s. If the i-th character of s is `1`,
  the i-th cell (from left) contains a token. Otherwise, it doesn't contain a
  token.
  
  Snuke wants to perform the following operation as many times as possible. In
  each operation, he chooses three consecutive cells. Let's call the cells X, Y,
  Z from left to right. In order for the operation to be valid, both X and Z
  must contain tokens and Y must not contain a token. Then, he removes these two
  tokens and puts a new token on Y.
  
  How many operations can he perform if he performs operations in the optimal
  way?
samples: [{"input": "7\n    1010101", "output": "2\n    \n\nFor example, he can perform two operations in the following way:\n\n  * Perform an operation on the last three cells. Now the string that represents tokens becomes `1010010`.\n  * Perform an operation on the first three cells. Now the string that represents tokens becomes `0100010`.\n\nNote that the choice of operations matters. For example, if he chooses three\ncells in the middle first, he can perform no more operations.\n\n* * *"}, {"input": "50\n    10101000010011011110001001111110000101010111100110", "output": "10"}]