#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}

int main() {
	string st; 
	while (getline(cin,st)) {
		if (st == "0")break;
		vector<string>sts(split(st,' '));
		vector<int>nums(sts.size());
		for (int i = 0; i < sts.size(); ++i) {
			nums[i] = stoi(sts[i]);
		}
		bool ace = false;
		for (int i = 0; i < sts.size(); ++i) {
			if (nums[i] >= 10)nums[i] = 10;
		}
		int sum = 0;
		for (int i = 0; i < sts.size(); ++i) {
			if (nums[i] == 1) {
				ace = true;
			}

			sum += nums[i];
		}
		if (sum <= 11 && ace)sum += 10;
		if (sum >= 22)sum = 0;
		cout << sum << endl;
	}
	return 0;
}