#!/usr/bin/env tclsh set total 0 set n 0 while {[gets stdin line] >= 0} { if {$line eq ""} { foreach c [array names answer] { if {$answer($c) == $n} {incr total} } array unset answer set n 0 continue } foreach c [split $line {}] { incr answer($c) } incr n } foreach c [array names answer] { if {$answer($c) == $n} {incr total} } puts $total