while~0:s="Qpp"+input();print(18//sum(max(s.count(c),2)for c in"pQRBN"))