#include<bits/stdc++.h>
using namespace std;

int main(){
    string s;
    cin >> s;
    while(s[0] != '0'){
        int ret = 0;
        for(auto it : s) ret += (it - '0');
        cout << ret << endl;
        cin >> s;
    }
 return 0;
}
