#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int i,test,length; int count =0;
char a[100];
cin>>test;
while(test--)
{
cin>>a;
length=strlen(a);
for(i=0;i<length;i++)
{
if(a[i]=='A'||a[i]=='D'||a[i]=='O'||a[i]=='P'||a[i]=='Q'||a[i]=='R')
{
++count;
}
if (a[i]== 'B')
{
count= count + 2;
}
}
}
cout<<count ;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPHN0cmluZy5oPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4oKQogICAgewogICAgaW50IGksdGVzdCxsZW5ndGg7IGludCBjb3VudCA9MDsKICAgIGNoYXIgYVsxMDBdOwogICAgY2luPj50ZXN0OwogICAgd2hpbGUodGVzdC0tKQogICAgICAgIHsKICAgICAgICBjaW4+PmE7CiAgICAgICAgICAgIGxlbmd0aD1zdHJsZW4oYSk7CiAgICAgICAgICAgIGZvcihpPTA7aTxsZW5ndGg7aSsrKQogICAgICAgIHsKICAgICAgICAgICAgaWYoYVtpXT09J0EnfHxhW2ldPT0nRCd8fGFbaV09PSdPJ3x8YVtpXT09J1AnfHxhW2ldPT0nUSd8fGFbaV09PSdSJykKCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgKytjb3VudDsKICAgICAgICAgICAgICAgIH0KCiAgICAgICAgICAgICAgICBpZiAoYVtpXT09ICdCJykKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgIGNvdW50PSBjb3VudCArIDI7CiAgICAgICAgICAgICAgICB9CgogICAgICAgIH0KICAgICAgICB9CgogICAgICAgIGNvdXQ8PGNvdW50IDsKICAgIH0=