#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main() {
	string s;
	while (getline(cin, s), s != "0") {
		stringstream ss(s);
		int cnt = 0;
		int n;
		while (ss >> n) {
			if (n < 10)cnt += n;
			else cnt += 10;
		}
		if (cnt + 10 <= 21)cnt += 10;
		cout << (cnt > 21 ? 0 : cnt) << endl;
	}
}