#include <bits/stdc++.h>
int main(void) {
  int i, sum = 0;
  char x[1001];
  scanf("%s", x);
  do {
    for (i = 0; i < 1001; i++) {
      if (x[i] == 0) {
        printf("%d\n", sum);
        break;
      } else {
        sum += x[i] - 0x30;
      }
    }
    sum = 0;
    scanf("%s", x);
  } while (x[0] != 0x30);
  return 0;
}
