#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<int> nums;

vector<string> split(string str, string delim)
{
	int pos = 0;
	vector<string> vec;
	while((pos=str.find_first_of(delim)) != str.npos)
	{
		if(pos > 0)
		{
			vec.push_back(str.substr(0, pos));
		}
		str = str.substr(pos + 1);
	}

	if(str.length() > 0)
	{
		vec.push_back(str);
	}

	return vec;
}

void solve()
{
	int sum = 0;
	int c = 0;
	for(int i=0; i<nums.size(); i++)
	{
		if(nums[i]>=10) sum += 10;
		else if(nums[i] != 1) sum += nums[i];
		else sum += 11, c++; 
	}

	for(int i=0; i<c; i++)
	{
		if(sum > 21) sum -= 10;
		else break;
	}
	sum = sum > 21 ? 0 : sum;
	cout << sum << endl;
}

int main(int argc, char** argv)
{
	string s;
	vector<string> vec;
	while(getline(cin, s) && s!="0")
	{
		vec = split(s, " ");
		nums.clear();
		for(int i=0; i<vec.size(); i++)
		{
			nums.push_back(atoi(vec[i].c_str()));
		}
		solve();
	}
}