output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      s
attempt: n = int(input())
  s = input()
  
  ss = []
  cnt = 0
  for c in s:
      if c == "1":
          cnt += 1
      else:
          if cnt > 0:
              ss.append(cnt)
              cnt = 0
          ss.append(cnt)
  if cnt > 0:
      ss.append(cnt)
  
  
  def solve(seq):
      l = len(seq)
      if not seq:
          return 0
      while seq[-1] == 0:
          seq.pop()
  
      # dp = [0]*(l+1)
      dp = [[0] * 3 for i in range(l + 1)]
      # print(seq)
      for i in range(l):
          # 0 -> 0, 1 -> 0, 2 -> 0
          nxt = max(dp[i])
          dp[i + 1][0] = max(dp[i + 1][0], nxt)
          if i + 1 < l:
              if seq[i] >= 2:
                  # 0 -> 1
                  dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + seq[i])
              if seq[i] >= 2 and seq[i + 1] >= 2:
                  # 1 -> 1
                  dp[i + 1][1] = max(dp[i + 1][1], dp[i][1] + seq[i] - 1)
                  # 2 -> 1
                  dp[i + 1][1] = max(dp[i + 1][1], dp[i][2] + 1)
                  # 1 -> 2
                  dp[i + 1][2] = max(dp[i + 1][2], dp[i][1] + max(seq[i], seq[i + 1]) - 1)
                  # 2 -> 2
                  dp[i + 1][2] = max(dp[i + 1][2], dp[i][2] + seq[i + 1] - 1)
              if seq[i + 1] >= 2:
                  # 0 -> 2
                  dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + max(seq[i], seq[i + 1] - 1))
          if i + 2 <= l:
              dp[i + 2][0] = max(dp[i + 2][0], dp[i][0] + max(seq[i], seq[i + 1]))
              if seq[i] >= 2:
                  dp[i + 2][0] = max(dp[i + 2][0], dp[i][1] + max(seq[i] - 1, seq[i + 1]))
          # print(dp[i])
      # print(dp[l])
      # print("-")
      return max(max(e) for e in dp)
  
  
  idx = 0
  cur = []
  ans = 0
  while idx < len(ss):
      if idx + 1 < len(ss) and ss[idx] == ss[idx + 1] == 0:
          idx += 2
          ans += solve(cur)
          cur = []
      elif not cur and ss[idx] == 0:
          idx += 1
      else:
          if ss[idx]:
              cur.append(ss[idx])
          idx += 1
  if cur:
      ans += solve(cur)
  print(ans)
  
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"}]