output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      s
attempt: # def makelist(n, m):
  #     return [[0 for i in range(m)] for j in range(n)]
  
  N = int(input())
  s = input()
  
  dp = []
  
  cnt = [0]*2
  cnt[int(s[0])] += 1
  for i in range(1, N):
      if i == N-1:
  
      else:
          now = int(s[i])
          if cnt[now] > 0:
              cnt[now] += 1
          else:
              anti = (cnt + 1) % 2
              if anti == 0:
                  dp.append(-cnt[anti])
              else:
                  dp.append(cnt[anti])
              cnt[anti] = 0
              cnt[now] = 1
  
  ans = 0
  nex = False
  pre = False
  for e in dp:
      if not start and e > 0:
          start = True
      else:
          continue
  
      if e > 0:
          if nex:
              nex = False
              pre = True
              ans += e
      elif e == -1:
          if pre:
              ans -= 1
              nex = True
          else:
              nex = True
          pre = False
      elif e <= -2:
          pre = False
          
  
  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"}]