<reponame>VolgaKurvar/AtCoder<gh_stars>0
n = int(input())
r = input()
#print(r.count('A'), r.count('B'), r.count('C'), r.count('D'))
print((r.count('A')*4+r.count('B')*3+r.count('C')*2+r.count('D'))/n)

n = int(input())
r = input()
#print(r.count('A'), r.count('B'), r.count('C'), r.count('D'))
print((r.count('A')*4+r.count('B')*3+r.count('C')*2+r.count('D'))/n)
#print(r.count('A'), r.count('B'), r.count('C'), r.count('D'))