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

int main() {
   string S;
  while(cin>>S&&S.at(0)!='0'){
    int ans=0;
   for(int i=0;i<S.size();i++){
     ans+=S.at(i)-'0';}
  cout<<ans<<endl;}
  return 0;
}
