output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      R G B N
attempt: N = int(input())
  AB_number = 0
  ab_cnt = 0
  a_cnt = 0
  b_cnt = 0
  for _ in range(N):
      s_i = input()
      AB_number += s_i.count("AB")
      if s_i[0] == "B" and s_i[-1] == "A":
          ab_cnt += 1
      elif s_i[-1] == "A":
          a_cnt += 1
      elif s_i[0] == "B":
          b_cnt += 1
  
  if ab_cnt == 0:
      print(AB_number + min(a_cnt, b_cnt))
      print(AB_number + min(a_cnt, b_cnt) - 1)
  elif a_cnt != b_cnt:
      print(AB_number + (ab_cnt - 1) + 1 + min(a_cnt, b_cnt))
  else:
      print(AB_number + (ab_cnt - 1) + min(a_cnt, b_cnt))
  
problem_description: Statement
  
  Snuke has come to a store that sells boxes containing balls. The store sells
  the following three kinds of boxes:
  
    * Red boxes, each containing R red balls
    * Green boxes, each containing G green balls
    * Blue boxes, each containing B blue balls
  
  Snuke wants to get a total of exactly N balls by buying r red boxes, g green
  boxes and b blue boxes. How many triples of non-negative integers (r,g,b)
  achieve this?
samples: [{"input": "1 2 3 4", "output": "4\n    \n\nFour triples achieve the objective, as follows:\n\n  * (4,0,0)\n  * (2,1,0)\n  * (1,0,1)\n  * (0,2,0)\n\n* * *"}, {"input": "13 1 4 3000", "output": "87058"}]