#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,c=0;
    string s;
    cin>>n;
    for (i=1;i<=n;i++) {
        cin>>s;
        if (s[0]>='H' && s[0]<='Q') {
            c++;    
        } 
        if (s[0]>='U' && s[0]<='Z') {
            c++;
        }
    }
    cout<<c<<endl;
 
    return 0;
}
 
/**************************************************************
	Problem: 1181
	User: wengsihan
	Language: C++
	Result: Accepted
	Time:9 ms
	Memory:2076 kb
****************************************************************/