#!/usr/bin/env tclsh8.6 set map1 {oneight oneeight twone twoone threeight threeeight fiveight fiveeight sevenine sevennine eightwo eighttwo eighthree eightthree nineight nineeight} set map2 {one 1 two 2 three 3 four 4 five 5 six 6 seven 7 eight 8 nine 9} set total 0 while {[gets stdin line] >= 0} { set first {} set last {} set line [string map $map1 $line] set line [string map $map2 $line] foreach c [split $line {}] { if {[string is digit $c]} { if {! [string length $first]} {set first $c} set last $c } } if {$first eq "0"} {set first {}} set number "$first$last" incr total $number } puts $total