#include <iostream>
#include <cstdio>
using namespace std;

int main(void)
{
	char c;
	int num;

	while(true){
		int x = 0;
		int one = 0;
		int sum = 0;
		while(scanf("%d", &num)){
			if(num > 10)
				num = 10;
			if(num == 1)
				one++;
			else
				sum += num;

			scanf("%c", &c);
			if(c == '\n')
				break;
		}
		if(num == 0 && one == 0)
			break;

		if(sum > 21)
			cout << 0 << endl;
		else {
			if(one > 0){
				if(sum + 11 + (one-1) <= 21)
					cout << sum + 11 + (one-1) << endl;
				else if(sum + one <= 21)
					cout << sum + one << endl;
				else
					cout << 0 << endl;
			}
			else
				cout << sum + one << endl;
		}

	}

	return 0;
}

		