#define	_USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
using namespace std;
int main(){
	
	string s;
	
	while(1){
		getline(cin,s);
		long long n=0;
		int	count=0;
		if(s=="0")
			break;
		else{
			string a="";
			for(int i=0;i<s.size();i++){
				if(s[i]!=' '){
					a=a+s[i];
				}
				else{
					int b=stoi(a);
					if(b==1)
						count+=11;
					else if(b>=2&&b<=9)
						n+=b;
					else
						n+=10;
					a="";
				}
			}
			int b=stoi(a);
					if(b==1)
						count+=11;
					else if(b>=2&&b<=9)
						n+=b;
					else
						n+=10;
					a="";
			while(count>0){
				if(n+count>21)
					n++;
				else
					n=n+11;
				count-=11;
			}
			
			if(n>21)
				cout<<0<<endl;
			else
				cout<<n<<endl;
		}
	}
	
	
	
	

}