#!/usr/bin/perl -w

use v5.38;
use strict;
use experimental 'multidimensional', 'for_list', 'builtin';
use builtin 'indexed';

my $sum;
my @digits = qw(zero one two three four five six seven eight nine);
my %map = reverse indexed @digits;
my $re = join('|', '\d', @digits);

while (<>) {
	my ($first) = /($re)/;
	my ($last)  = /.*($re)/;
	for ($first, $last) {
		$_ = $map{$_} if !/\d/;
	}
	$sum += "$first$last";
	# say "$_ $first $last.";
}

say $sum;
