output_description: If it is possible to change S into `AKIHABARA`, print `YES`; otherwise, print
  `NO`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: #!/usr/bin/env python3
  #CODE FESTIVAL 2017 Final A
  
  import sys
  import math
  import bisect
  sys.setrecursionlimit(1000000000)
  from heapq import heappush, heappop,heappushpop
  from collections import defaultdict
  from itertools import accumulate
  from collections import Counter
  from collections import deque
  from operator import itemgetter
  from itertools import permutations
  mod = 10**9 + 7
  inf = float('inf')
  def I(): return int(sys.stdin.readline())
  def LI(): return list(map(int,sys.stdin.readline().split()))
  
  s = input()
  lst = ['A','K','I','H','B','R']
  for i in range(len(s)):
      if s[i] not in lst:
          print('NO')
          quit()
  a = s.count('A')
  t = ''
  for i in range(len(s)):
      if s[i] != 'A':
          t += s[i]
  if 'KIHBR' not in t or a > 4 or 'KIH' not in s:
      print('NO')
      quit()
  if t.count('K') != 1 or t.count('I') != 1 or t.count('H') != 1 or t.count('B') != 1 or t.count('R') != 1:
      print('NO')
      quit()
  a = 0
  for i in range(len(s)):
      if s[i] == 'K':
          if s[:i].count('A') > 1:
              print('NO')
              quit()
      if s[i] == 'H':
          for j in range(i+1.len(s)):
              if s[j] == 'B':
                  if s[i:j].count('A') > 1:
                      print('NO')
                      quit()
      if s[i] == 'B':
          for j in range(i+1,len(s)):
              if s[j] == 'R':
                  if s[i:j].count('A') > 1:
                      print('NO')
                      quit()
      if s[i] == 'R':
          if s[i:].count('A') > 1:
              print('NO')
              quit()
  print('YES')
  
problem_description: Statement
  
  You are given a string S.
  
  Takahashi can insert the character `A` at any position in this string any
  number of times.
  
  Can he change S into `AKIHABARA`?
samples: [{"input": "KIHBR", "output": "YES\n    \n\nInsert one `A` at each of the four positions: the beginning, immediately after\n`H`, immediately after `B` and the end.\n\n* * *"}, {"input": "AKIBAHARA", "output": "NO\n    \n\nThe correct spell is `AKIHABARA`.\n\n* * *"}, {"input": "AAKIAHBAARA", "output": "NO"}]