#include <bits/stdc++.h>
using namespace std;
const int dx[]={0,1,0,-1,1,-1,-1,1};
const int dy[]={-1,0,1,0,1,1,-1,-1};
const int INF = 1<<30;
const double EPS = 1e-15;
#define PB push_back
#define mk make_pair
#define fi first
#define se second
#define ll long long
#define reps(i,j,k) for(int i = (j); i < (k); i++)
#define rep(i,j) reps(i,0,j)
#define MOD 1000000007
typedef pair<int,int> Pii;
typedef pair<int,Pii> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	string str;
	while(true){
		getline(cin,str);
		if(str.size() == 1 && str[0] == '0')break;
		vi num;
		stringstream ss(str);
		int tmp;
		while(ss >> tmp){
			num.PB(tmp);
		}
		sort(num.begin(),num.end());
		int one = 0;
		int ans = 0;
		rep(i,num.size()){
			if(num[i]==1)one++;
			if(num[i] > 1){
				if(num[i] > 9){
					ans+=10;
				}
				else{
					ans+=num[i];
				}
			}
		}
		if(one == 1){
			if(ans+11<22)ans += 11;
			else ans++;
		}
		else{
			ans += one;
		}
		if(ans >= 22)ans = 0;
		printf("%d\n",ans);
    }
    return 0;
}