#!/usr/bin/perl -w

use v5.16;

my %score_of = (
	'(' => 1,
	'[' => 2,
	'{' => 3,
	'<' => 4,
);

my @sums;
while (<>) {
	chomp;
	my $sum = 0;
	1 while s/\(\)|\[\]|\{\}|\<\>//;
        next if /[\)\]\}\>]/;
	next if !length;
	for my $c (reverse split //) {
		$sum *= 5;
		$sum += $score_of{$c};
	}
	push @sums, $sum;
}

@sums = sort { $a <=> $b } @sums;
say $sums[@sums/2];

