#include <iostream>
using namespace std;
int main()
{
	int n, p, t, i;
	while (1)
	{
		p = 0;
		t = 0;
		while (1)
		{
			cin >> n;
			if (n == 0) return 0;
			if (2 <= n && n <= 9)
				p += n;
			else if (n >= 10)
				p += 10;
			else
			{
				t++;
				p++;
			}
			if (cin.get() == '\n')
				break;
		}
		for (i = 0; i < t; i++)
		{
			if (p + 10 <= 21)
				p += 10;
		}
		if (p > 21)
		{
			p = 0;
		}
		cout << p << endl;
	}
}