f = open('24.txt')
k = 0
for line in f:
ka = 0
ke = 0
s = str(f.readline())
for i in range(1, len(s)):
if s[i] == 'A':
ka += 1
elif s[i] == 'E':
ke += 1
if ke > ka:
k += 1
f.close()
print(k)
for line in f:
s = str(f.readline())
k = 0
with open('24.txt') as f:
for line in f:
ka = 0
ke = 0
for char in line:
if char == 'A':
ka += 1
elif char == 'E':
ke += 1
if ke > ka:
k += 1
print(k)