#!/usr/bin/perl -w

use v5.36;
use strict;
use experimental 'multidimensional';

my $sum;
while (<>) {
	chomp;
	$sum += 1 if /X/;
	$sum += 2 if /Y/;
	$sum += 3 if /Z/;

	$sum += 3 if /A X/;
	$sum += 3 if /B Y/;
	$sum += 3 if /C Z/;

	$sum += 6 if /A Y/;
	$sum += 6 if /B Z/;
	$sum += 6 if /C X/;
}

say $sum;

