// 2011/02/26 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

int main()
{
	while(true){
		string str;
		getline(cin, str);
		istringstream ist(str);

		int crd;
		int sum = 0;
		int flg = false;
		while(ist >> crd){
			if(crd==0){
				return 0;
			}
			else if(crd==1){
				sum += 1;
				flg = true;
			}
			else if(crd>=2&&crd<=9){
				sum += crd;
			}
			else if(crd>=10&&crd<=13){
				sum += 10;
			}

			if(sum>21)
				break;
		}

		if(sum<=11&&flg)
			sum += 10;

		if(sum>21)
			sum = 0;

		cout << sum << endl;
	}
}