output_description: Print the number of permutations that can be produced as P after the
  operation.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      P_0 P_1 \cdots P_{N-1}
attempt: from heapq import heappush, heappop
  
  N, K, *P = map(int, open("0").read().split())
  mhq = []
  Mhq = []
  for c in P[:K]:
      heappush(mhq, c)
      heappush(Mhq, -c)
  
  ans = 1
  log = set()
  for i, c in enumerate(P[K:]):
      while mhq[0] in log:
          heappop(mhq)
      while -Mhq[0] in log:
          heappop(Mhq)
      d = P[i]
      m = mhq[0]
      M = -Mhq[0]
      log.add(d)
      heappush(mhq, c)
      heappush(Mhq, -c)
      if not (m == d and M < c):
          ans += 1
  p = P[0]
  m = 1
  x = 0
  for c in P[1:]:
      if p < c:
          m += 1
      else:
          if m >= K:
              x += 1
          m = 1
      p = c
  if m >= K:
      x += 1
  print(ans - x + 1)
  
problem_description: Statement
  
  Snuke has a permutation (P_0,P_1,\cdots,P_{N-1}) of (0,1,\cdots,N-1).
  
  Now, he will perform the following operation **exactly once** :
  
    * Choose K consecutive elements in P and sort them in ascending order.
  
  Find the number of permutations that can be produced as P after the operation.
samples: [{"input": "5 3\n    0 2 1 4 3", "output": "2\n    \n\nTwo permutations can be produced as P after the operation: (0,1,2,4,3) and\n(0,2,1,3,4).\n\n* * *"}, {"input": "4 4\n    0 1 2 3", "output": "1\n    \n\n* * *"}, {"input": "10 4\n    2 0 1 3 7 5 4 6 8 9", "output": "6"}]