#!/usr/bin/perl -w

use v5.16;

my %score_of = (
	')' => 3,
	']' => 57,
	'}' => 1197,
	'>' => 25137,
);

my $sum;
while (<>) {
	chomp;
	1 while s/\(\)|\[\]|\{\}|\<\>//;
	s/^[\(\[\{\<]*//;
	next if !length;
	$sum += $score_of{substr($_, 0,1)};
}

say $sum;

