#include<iostream>
#include<algorithm>
#include<sstream>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s;
    while(getline(cin,s)){
        stringstream ss(s);
        vector<int> V;
        int x;
        while(ss>>x){
            V.push_back(x);
        }
        if(V[0] == 0)break;
        int ans = 0;
        int num = 0;
        for(int i = 0;i < V.size();i++){
            if(V[i] == 1)ans += 1,num++;
            else if(V[i] > 9)ans += 10;
            else ans += V[i];
        }
        if(num>0 && ans<=11)ans += 10;
        if(ans > 21)ans = 0;
        cout<<ans<<endl;
    }
}