Problem: Vasya plays Robot Bicorn Attack.

The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtained points one by one (without leading zeros) into the string s. Vasya decided to brag about his achievement to the friends. However, he has forgotten how many points he got for each round. The only thing he remembers is the string s.

Help Vasya to find out what is the maximum amount of points he could get. Take into account that Vasya played Robot Bicorn Attack for the first time, so he could not get more than 1000000 (106) points for one round.

Input

The only line of input contains non-empty string s obtained by Vasya. The string consists of digits only. The string length does not exceed 30 characters.

Output

Print the only number — the maximum amount of points Vasya could get. If Vasya is wrong and the string could not be obtained according to the rules then output number -1.

Examples

Input

1234


Output

37


Input

9000


Output

90


Input

0009


Output

-1

Note

In the first example the string must be split into numbers 1, 2 and 34.

In the second example the string must be split into numbers 90, 0 and 0. 

In the third example the string is incorrect, because after splitting the string into 3 numbers number 00 or 09 will be obtained, but numbers cannot have leading zeroes.

Solution (in JAVA):

Solution:
import java.util.Scanner;
import java.util.Arrays;
import java.math.*;
public class codeforce{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = new String();
        s = sc.next();
        int nb=0;
        String ks = s;
        int ind;
        for(int k=0;k<3;k++){
            ind = ks.indexOf("1000000");
            if(ind==-1) break;
            nb++;
            if(ind+7>=s.length()) break;
            ks = ks.substring(ind+7,ks.length());
        }
        int v = s.length();
        if(v>21) System.out.println("-1");
        else if(v==21&&nb!=3) System.out.println("-1");
        else if(v==20&&nb<2) System.out.println("-1");
        else if(v==19&&nb==0) System.out.println("-1");
        else{
            String ns = new String();
            int[] t = new int[s.length()];
            int l1,l2,ld=-1,l=-1;
            int n,i,nn;
            n = 6;
            if(s.indexOf("1000000")==0) n =7;
            for(i=n;i>0;i--){
                if(i<s.length())
                if(v-i>=2 && v-i<=14){
                    
                    if(i>1 && s.charAt(0)=='0') continue;
                    
                    
                    ind = s.substring(i,v).indexOf("1000000");
                    if(v-i>=13 && ind==-1) break;
                    else if(v-i==14 && ind!=0){
                        ind = s.substring(7,v).indexOf("1000000");
                        if(ind==-1) break;
                    }
                    ld = -1;
                    nn = 6;
                    int j;
                    ns = s.substring(i,v);
                    if(ns.indexOf("1000000")==0) nn = 7;
                    
                    int k=-1;
                    for(j=nn;j>0;j--){
                        if(j<ns.length())
                        if(ns.length()-j>=1 && ns.length()-j<=7){
                            
                            ind = ns.substring(j,ns.length()).indexOf("1000000");
                            if(ns.length()-j==7&&ind==-1) break;
                            l1 = Integer.valueOf(ns.substring(0,j)).intValue();
                            l2 = Integer.valueOf(ns.substring(j,ns.length())).intValue();
                            
                            if(ns.substring(0,j).length()!=1 && ns.charAt(0)=='0') continue;
                            
                            if(ns.substring(j,ns.length()).length()!=1 && ns.charAt(j)=='0'){ continue;}
                            if(ld<l1+l2) {ld = l1+l2;k =j ;}
                            
                            
                            
                        }
                    }
                    
                   
                    
                    
                    if(ld!=-1){
                        
                        l1 = Integer.valueOf(s.substring(0,i)).intValue();;
                        if(l<l1+ld) l = l1+ld;
                        
                    }
                    
                }
            }
            
            System.out.println(l);
        }
        
        
        
    }
    

    
}