output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
attempt: N = int(input())
  s = ""
  point = 0
  q1, q2, q3 = 0, 0, 0  # q1はBA q2はAの末尾のみ q3はBの最初のみ
  for j in range(N):
      n = str(input())
      point += n.count("AB")
      if n[0] == "B" and n[len(n) - 1] == "A":
          q1 += 1
      elif n[0] == "B":
          q2 += 1
      elif n[len(n) - 1] == "A":
          q3 += 1
      else:
          pass
  q1 -= 1
  q2 -= 1
  print(q1 - 1 + 2 + min(q3, q2) + point)
  
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"}]