first_line = input()
n = int(first_line)
second_line = input()
parts = second_line.split()
records = parts[0:n]
total = 0
best = 0
current = 0
for rec in records:
cmd = rec[0]
dur = int(rec[1:])
if cmd == "F" or cmd == "B":
current = current + dur
total = total + dur
if current > best:
best = current
else:
current = 0
print(total, best)