Загрузка данных


n = int(input())

all_records = ""
while True:
    try:
        all_records = all_records + " " + input()
    except EOFError:
        break

parts = all_records.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)