#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
#include<stack>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int main(void){
  string str;
  while(getline(cin,str),str!="0"){
    int a,b,c;  a = b = c = 0;
    sscanf(str.c_str(), "%d %d %d", &a, &b, &c);
    //cout<<a<<" "<<b<<" "<<c<<endl;
    if(10<=a)a=10;  if(10<=b)b=10;  if(10<=c)c=10;
    int sum = a + b + c;
    if(sum < 11 && (a==1 || b ==1 || c == 1)) sum += 10;

    cout<<(sum<=21?sum:0)<<endl;
  }
}