#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	string s;
	int tmp;
	while(getline(cin, s)) {
		if(s == "0") break;
		stringstream ss(s);
		vector<int> v;
		while(!ss.eof()) {
			ss >> tmp;
			v.push_back(tmp);
		}
		int ret = 0, cnt = 0;
		bool f = 0;
		rep(i, v.size()) {
			if(v[i] > 10) ret += 10;
			else if(v[i] == 1) cnt++; 
			else ret += v[i];
		}
		ret += cnt;
		while(cnt-- && ret < 12) {
			ret += 10;
		}
		if(ret >= 22) f = 1;
		if(f) cout << 0 << endl;
		else cout << ret << endl;
	}
    return 0;
}