output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
attempt: # -*- coding: utf-8 -*-
  # input
  a = int(input())
  s = 0
  bc = 0
  ac = 0
  tc = 0
  for i in range(a):
      t = input()
      s += t.count("AB")
      if t[:1] == "B":
          bc += 1
      if t[-1:] == "A":
          ac += 1
      if t[:1] == "B" or t[-1:] == "A":
          tc += 1
  if min(bc, ac) == tc and tc > 0:
      o = s + min(bc, ac) - 1
  else:
      o = s + min(bc, ac)
  print(o)
  
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"}]