output_description: Print the minimum required number of operations
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      p_1 p_2 .. p_N
attempt: import sys
  from collections import deque, Counter, defaultdict
  from fractions import gcd
  input = sys.stdin.readline
  
  def eprint(s):
      if type(s) != type('str'):
          s=str(s)
  
      sys.stderr.write(s+'\n')
      return
  
  def check(h):
      n = len(h)
      cps = [False]*n
      for i in range(n):
          if h[i] != i+1:
              cps[i] = True
      return cps
          
  
  def main():
      n = int(input())
      Ps = list(map(int, input().split()))
      cnt = int()
      #となりあうFalseは絶対にTrueになる
      cps = check(Ps)
      for i in range(n):
          if not cps[i]:
              if i = n-1:
                  cps[i], cps[i-1] = cps[i-1], cps[i]
              else:
                  cps[i], cps[i+1] = True, True
              cnt += 1
      eprint(cps)
      print(cnt)
      return
  
  if __name__ == '__main__':
      main()
  
problem_description: Statement
  
  You are given a permutation p_1,p_2,...,p_N consisting of 1,2,..,N. You can
  perform the following operation any number of times (possibly zero):
  
  Operation: Swap two **adjacent** elements in the permutation.
  
  You want to have p_i ≠ i for all 1≤i≤N. Find the minimum required number of
  operations to achieve this.
samples: [{"input": "5\n    1 4 3 5 2", "output": "2\n    \n\nSwap 1 and 4, then swap 1 and 3. p is now 4,3,1,5,2 and satisfies the\ncondition. This is the minimum possible number, so the answer is 2.\n\n* * *"}, {"input": "2\n    1 2", "output": "1\n    \n\nSwapping 1 and 2 satisfies the condition.\n\n* * *"}, {"input": "2\n    2 1", "output": "0\n    \n\nThe condition is already satisfied initially.\n\n* * *"}, {"input": "9\n    1 2 4 9 5 8 7 3 6", "output": "3"}]