#include <iostream>

using namespace std;

int rec(int sum, int one)
{
    if (one == 0 && sum > 21)
        return -1;
    else if (one == 0 && sum <= 21)
        return sum;

    int res = rec(sum + 1, one - 1);
    res = max(res, rec(sum + 11, one - 1));

    return res;
}

bool solve(string &s)
{
    int sum = 0, one = 0;
    int index = 0;

    s += " ";
    while (index < s.size()) {
        int num = 0;

        while (index < s.size()) {
            if ('0' <= s[index] && s[index] <= '9') {
                num *= 10;
                num += (int)(s[index] - '0');
                index++;
            }
            else
                break;
        }

        if (num == 1)
            one++;
        else if (num / 10 == 1)
            sum += 10;
        else
            sum += num;
        index++;
    }

    if (sum == 0 && one == 0)
        return false;

    if (sum > 21) {
        cout << 0 << endl;
        return true;
    }
    else if (one == 0) {
        cout << sum << endl;
        return true;
    }
    else {

        int ans = rec(sum, one);
        if (ans >= 0)
            cout << ans << endl;
        else
            cout << 0 << endl;
        return true;
    }
}

int main()
{
    string s;

    while (true) {
        getline(cin, s);
        if (!solve(s))
            break;
    }

    return 0;
}