#!/usr/bin/perl -w

use strict;
use v5.30;

sub str_len {
	my ($in) = @_;
	my $l = 0;
	while ($in) {
		$l++ while $in =~ s/\A[A-Z]//;
		next if $in !~ /\A\((\d+)x(\d+)\)/;
		my $str = substr($in, length("($1x$2)"), $1);
		substr($in, 0, length("($1x$2)") + $1) = '';
		my $c = $2;
		$l += $c * str_len($str);
	}
	return $l;
}

chomp (my $in = <>);
say str_len($in);
