#!/usr/bin/perl -w

use v5.16;

my @timers;

for (split /,/, <>) {
	$timers[$_]++;
}

my $days = 80;

while ($days--) {
	my $zero = shift @timers;
	$timers[6]+=$zero;
	$timers[8]+=$zero;
}

my $sum = 0;
$sum += $_ for @timers;

say $sum;

	

