#include <iostream>

int getScore(int h[], int n)
{
	int res = 0;
	int one_count = 0;
	for (int i=0; i<n; i++) {
		if (2 <= h[i] && h[i] <= 9) res += h[i];
		else if (h[i] >= 10) res += 10;
		else { res++; one_count++; }
	}
	if (res >= 22) return 0;
	else {
		while (res<=11 && one_count>0) { res += 10; one_count--; }
		return res;
	}
}

int main()
{
	int hand[100];
	std::string input;
	while (true) {
		getline(std::cin, input);
		int offset = 0;
		int pos;
		int index = 0;
		int h;
		while ( (pos = input.find(' ', offset)) != std::string::npos ) {
			h = std::stoi(input.substr(offset, pos-offset));
			hand[index] = h; index++;
			offset = pos + 1;
		}
		h = std::stoi(input.substr(offset));
		if (h==0) break;
		hand[index] = h;
		std::cout << getScore(hand, index+1) << std::endl;
	}
	return 0;
}

