#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int check(int n){
  if(n > 21) return 0;
  return n;
}
int main(void){
  int n,sum=0,f=0;
  while(cin >> n && n){
    if(n>10) n = 10;
    if(n==1) f = 10;
    sum += n;
    if(getchar() == '\n'){
      cout << max(check(sum),check(sum+f)) << endl;
      sum = 0;
      f = 0;
    }
  }
}