#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  while(true){
    vector<int> v;
    string str;
    getline(cin, str);
    stringstream ss(str);
    int tmp;
    while(ss>>tmp){
      if(tmp == 0) goto end;
      if(tmp > 10) tmp = 10;
      v.push_back(tmp);
    }
    sort(v.begin(), v.end());
    int sum = accumulate(ALL(v), 0);
    if(sum < 12 && v[0] == 1)
      sum += 10;
    if(sum > 21) sum = 0;
    cout << sum << endl;
  }
 end:
  return 0;
}