#include<iostream>
#include<cstdio>
using namespace std;

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;
}