#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string plays[] = {"A X", "A Y", "A Z", "B X", "B Y", "B Z", "C X", "C Y", "C Z"};
int play_scores[] = {1 + 3, 2 + 6, 3 + 0, 1 + 0, 2 + 3, 3 + 6, 1 + 6, 2 + 0, 3 + 3};

int main(int argc, char* argv[])
{
    int total_score = 0;
    string line;
    while(getline(cin, line))
    {
        int i = find(&plays[0], &plays[9], line)-&plays[0];
        total_score += play_scores[i];
    }
    cout << total_score << endl;
}