output_description: Print number of occurrences of `ABC` in S as contiguous subsequences.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      S
attempt: from collections import deque
  
  
  N, K = map(int, input().split())
  P = list(map(int, input().split()))
  
  smin = deque()
  smax = deque()
  x = 0
  r = 0
  r2 = 0
  
  for i, p in enumerate(P):
      while len(smin) > 0 and P[smin[-1]] > p:
          smin.pop()
      smin.append(i)
      if smin[0] <= i - K:
          smin.popleft()
      while len(smax) > 0 and P[smax[-1]] < p:
          smax.pop()
      smax.append(i)
      if smax[0] <= i - K:
          smax.popleft()
      if i > 0 and P[i - 1] < P[i]:
          x = min(x + 1, K - 1)
      else:
          x = 0
      if i == K - 1 or (i >= K and not (P[i - K] < P[smin[0]] and smax[0] == i)):
          if x != K - 1:
              r += 1
          else:
              r2 = 1
  print(r + 1 if r2 else r)
  
problem_description: Statement
  
  We have a string S of length N consisting of uppercase English letters.
  
  How many times does `ABC` occur in S as contiguous subsequences (see Sample
  Inputs and Outputs)?
samples: [{"input": "10\n    ZABCDBABCQ", "output": "2\n    \n\nTwo contiguous subsequences of S are equal to `ABC`: the 2-nd through 4-th\ncharacters, and the 7-th through 9-th characters.\n\n* * *"}, {"input": "19\n    THREEONEFOURONEFIVE", "output": "0\n    \n\nNo contiguous subsequences of S are equal to `ABC`.\n\n* * *"}, {"input": "33\n    ABCCABCBABCCABACBCBBABCBCBCBCABCB", "output": "5"}]