#!/usr/bin/perl -w

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

my $sum;
my $s;
while (<>) {
	$s .= $_;
	next if $. % 3;
	$_ = $s;
	$s = '';
	my ($c) = /(.)\S*\s\S*\1\S*\s\S*\1/;
	$sum += $c =~ /[A-Z]/
		? ord($c) - ord('A') + 27
		: ord($c) - ord('a') + 1; 
}
say $sum;
