#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
  int n;
  char c;
  int ans,ace;
 
 while(1){
    ans = 0;
    ace = 0;
 
    while(1){
      c = getchar();
      if(c=='0')goto Loop;
      if(c=='\n')break;
      else if(c!=' '){
    n = c-'0';
    if(n==1){
      c = getchar();
      if(c=='\n'){
        ans += 1;
        ace = 1;
        break;
      }else if(c!=' '){
        ans += 10;
      }else{
        ans += 1;
        ace = 1;
      }
    }else{
      ans += n;
    }
      }
    }
 
    if(ans<12 && ace)ans+=10;
    if(ans>21)ans = 0;
    cout << ans << endl;
  }
 Loop:return 0;
}
