#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

vector<int> split(string s){
    if(s.size()==1) return vector<int>(1,stoi(s));
    vector<int> ret;
    int x = -1;
    REP(i,s.size()){
	if(s[i] == ' '){
	    ret.PB(stoi(s.substr(x+1,i-x-1)));
	    x = i;
	}
    }
    ret.PB(stoi(s.substr(x+1,s.size()-x)));
    return ret;
}

int main(){
    while(true){
	string s;
	getline(cin,s);
	if(s == "0") break;
	vector<int> c = split(s);
	int ans = 0;
	bool flg = false;
	REP(i,c.size()){
	    if(c[i] >= 10) ans += 10;
	    else ans += c[i];
	    if(c[i]==1) flg = true;
	}
	if(ans <= 11 && flg) ans += 10;
	if(ans > 21) ans = 0;
	cout << ans << endl;
    }
    return 0;
}