eval(input());a=[0]

for x in eval(input()):a+=[a[-1]+((x>'D')or-1)]

print((max(a)))
eval(input());a=b=0

for x in eval(input()):b+=x>'D'or-1;a=max(a,b)

print(a)
eval(input())
a = [0]
for x in eval(input()):
    a += [a[-1] + ((x > "D") or -1)]
print((max(a)))

eval(input())
a = b = 0
for x in eval(input()):
    b += x > "D" or -1
    a = max(a, b)
print(a)

-a = [0] +a = b = 0 -    a += [a[-1] + ((x > "D") or -1)] -print((max(a))) +    b += x > "D" or -1 +    a = max(a, b) +print(a)