include[HTML_REMOVED]
using namespace std;
const int N=1e6+10;
int mm[N];
int main()
{
mm[‘J’]=1,mm[‘Q’]=2,mm[‘K’]=3;
mm[‘A’]=4;
int n;
cin>>n;
int ans=0;
while(n–)
{
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
ans+=mm[s[i]];
}
}
cout<<ans<<endl;
}