#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
  string s;
  while (getline(cin, s), s != "0"){
    int sum = 0;
    for (int i = 0; i < s.size(); i++){
      sum += (s[i] - '0');
    }

    cout << sum << endl;
  }
}