while 1 {puts [expr -1+~-[join [gets stdin] *~-]]}