#include <iostream> #include <stdio.h> using namespace std; int main() { // your code goes here char cs[1001]; while(1){ scanf("%s",cs); if(cs[0]=='0'&&cs[1]=='\0')break; int ans=0; for(int i=0;cs[i]!='\0';i++){ ans+=cs[i]-'0'; } printf("%d\n",ans); } return 0; }