#!/usr/bin/env python3 import sys import regex as re num_values = dict( one=1, two=2, three=3, four=4, five=5, six=6, seven=7, eight=8, nine=9, ) sum = 0 for line in sys.stdin: nums = re.findall(r"one|two|three|four|five|six|seven|eight|nine|[1-9]", line, overlapped=True) nums = [str(num_values.get(x, x)) for x in nums] first = nums[0] last = nums[-1] value = int(first + last) sum += value print(sum)