object Main extends App{
    override def main(args:Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        var sum = 0L
        Iterator.continually(new Datum(sc.nextLine)).takeWhile(_.isContinue)
        .foreach(d => sum = sum + d.getValue)
        println(sum)
    }
    
    case class Datum(buf:String){
    	val isContinue = buf != "0"
    	
    	val getValue = {
    		buf.foldLeft(0){(z,n) => z + n - '0'}
    	}
    }
}