#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

int main(){

  int n;
  char c;
  int sum = 0;
  vector<int> V;

  while(1){
    scanf("%d%c",&n,&c);
    if(n == 0) break;
    
    V.push_back(n);
    if(c == '\n'){
      int first = 0;
      for(int i = 0; i < V.size(); i++){
	if(V[i] > 10) V[i] = 10;

	if(V[i] != 1) sum += V[i];
	else first++;
      }

      if(sum+(first*11) <= 21) sum += (first*11);
      else sum += first;

      if(sum > 21) sum = 0;
    }else{
      continue;
    }
    cout << sum << endl;
    sum = 0;
    V.clear();
  }

  return 0;
}