#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  long long a;
  while (cin >> a, a){
    int sum = 0;
    while(a){
      sum += (a % 10);
      a /= 10;
    }
    cout << sum << endl;
  }
}