#include<cstdio>
#include<sstream>
#define MAX(x,y) ((x>y)?x:y)
using namespace std;

int main(){
	int i,j,x,sum,f,ans;
	char s[200];
	
	while(fgets(s,200,stdin)!=NULL){
		istringstream ss(s);
		f=sum=0;
		while(ss>>x){
			if(x==0)goto fin;
			if(x==1)f++;
			else if(x>9)sum+=10;
			else sum+=x;
		}
		ans=0;
		for(i=0;i<=f;i++){
			x=sum+i+11*(f-i);
			if(x>21)x=0;
			ans=MAX(ans,x);
		}
		printf("%d\n",ans);
	}
	fin:
	
	return 0;
}