output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
attempt: n = int(input())
  s = ["" for i in range(n)]
  for i in range(n):
      s[i] = input()
  # print(n,s)
  cnt = 0
  cnta = 0
  cntb = 0
  cntab = 0
  ans = 0
  for i in range(n):
      cnt += s[i].count("AB")
      if s[i][-1] == "A" and s[i][0] == "B":
          cntab += 1
      elif s[i][-1] == "A":
          cnta += 1
      elif s[i][0] == "B":
          cntb += 1
  
  if cntab == 0:
      ans = cnt + min(cnta, cntb)
  else:
      ans = cnt + cntab + min(cnta, cntb)
  
  if cnta == 0 and cntb == 0:
      if cntab > 0:
          ans = cnt + cntab - 1
      else:
          ans = cnt
  print(ans)
  
problem_description: Statement
  
  Snuke has N integers: 1,2,\ldots,N. He will choose K of them and give those to
  Takahashi.
  
  How many ways are there to choose K consecutive integers?
samples: [{"input": "3 2", "output": "2\n    \n\nThere are two ways to choose two consecutive integers: (1,2) and (2,3).\n\n* * *"}, {"input": "13 3", "output": "11"}]