#include<bits/stdc++.h>
using namespace std;
int main(){
int t,cnt,b=0,a[26]={1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4};
cin>>t>>ws;
while(t--){
b++;
cnt=0;
string s;
getline(cin,s);
for(int i=0;i<s.size();i++){
if(s[i]==' ')cnt++;
else cnt+=a[s[i]-'a'];
}
cout<<"Case #"<<b<<": "<<cnt<<endl;
}
}