#include<cstdio>
#include<cstring>

int main() {
	char x[1000];
	
	while(1){
		scanf("%s", x);
		if (x[0] == '0') break;
		
		int i = 0; int sum = 0;
		while (x[i]) {
			sum += (x[i] - '0');
			i++;
		}
		printf("%d\n", sum);
	}

	return 0;
}

