$_=<>;y/cw//cd;$c+=$+[1],$s+=($f+$c*~-($w=$+[2]-$-[2])/2)*$w,$f+=$c*$w while s/(c*)(w+)//;print$s+0