#!/usr/bin/perl -w

use strict;

my $sum = 0;
while (<>) {
	s/\s//g;
	$_ = "($_)";
	1 while
		s/\((\d+)\)/$1/ ||
		s/(\([^\(\)]*?)(\d+)\+(\d+)([^\(\)]*\))/$1.($2+$3).$4/e ||
		s/(\([^\(\)]*?)(\d+)\*(\d+)([^\(\)]*\))/$1.($2*$3).$4/e;
	$sum += $_;
}
print "sum=$sum\n";
