#!/usr/bin/env tclsh8.6 set total 0 while {[gets stdin line] >= 0} { set first {} set last {} 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