#!/usr/bin/perl -w

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

my $sum;

my %map = (
	one   => 1,
	two   => 2,
	three => 3,
	four  => 4,
	five  => 5,
	six   => 6,
	seven => 7,
	eight => 8,
	nine  => 9,
);

while (<>) {
	my ($first) = /(\d|one|two|three|four|five|six|seven|eight|nine)/;
	my ($last)  = /(?:.*)(\d|one|two|three|four|five|six|seven|eight|nine)/;
	$first = $map{$first} if exists $map{$first};
	$last =  $map{$last}  if exists $map{$last};
	$sum += "$first$last";
	# say "$_ $first $last.";
}

say $sum;
