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;

/**
 *
 * @author CuteCoke
 */
public class A2 {
	int MAX_POINT = 1000000;
	int MAX_DIGIT = 7;
	boolean bDebug = false;
    public int solve(String s){
		
		int l = s.length();
		int m = -1;
		
		// 3 numbers will be 0~i, i~j, j~length
		// j~length: at least 1 digit, i.e. max_j will be length-1
		// i~j: at least 1 digit, i.e. max_i will be max_j - 1, min_j will be i+1.
		// 0~i: at least 1 digit, i.e. min_i = 1
		// Since all case will not exceed 7 digit, so max_x = min(max_x, 7)
		
		int max_j = l-1; 	// Since index start with 0, not 1, so -1 more.
		int max_i = max_j-1;
		max_j = Math.min(max_j, MAX_DIGIT*2);
		max_i = Math.min(max_i, MAX_DIGIT);
		if (bDebug) System.out.println("============");
		if (bDebug) System.out.println(" max_i="+max_i+"; max_j="+max_j+"; ");
		if (bDebug) System.out.println("============");
		
		l1: for(int i=1; i<=max_i; i++){
			l2: for(int j=i+1; j<=max_j; j++){
				if (bDebug) System.out.println("------------");
				if (bDebug) System.out.println(" i="+i+"; j="+j+"; ");
				if (bDebug) System.out.println("------------");
				int iSum = 0;
				String sSum = "";
				l3: for(int k=0; k<3; k++){
					String sTmp = "";
					if(k==0) sTmp = s.substring(0,i);
					if(k==1) sTmp = s.substring(i,j);
					if(k==2) sTmp = s.substring(j,l);
					if (bDebug) System.out.println("["+k+"] = "+sTmp);
					if (sTmp.length()>=2 && sTmp.startsWith("0")){ // Check leading zero case
						if (k==0) break l1; 	
						if (k==1) continue l1; 	
						continue l2; 	
					}
					if (sTmp.length()>MAX_DIGIT) continue l2; // Check if over MAX_DIGIT
					int iTmp = Integer.parseInt(sTmp);
					if (iTmp>MAX_POINT) continue l2; // Check Max Point
					iSum+=iTmp;
					sSum+=sTmp;
				}
				if (sSum.length()!=l) continue l2; // Check if all digit has been used
				m = Math.max(m,iSum);
			}
		}

        return m;
    }
	
    public void doMain() throws Exception{
		if (bDebug) System.out.println("Please enter input:");
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
        int ans = solve(s);
		System.out.println(ans);
    }

    public static void main(String[] s) throws Exception{
        try{
            A2 test = new A2();
            test.doMain();
        }catch(Exception e){
            e.printStackTrace(System.err);
        }
    }
}

/*
Analysis:
- A number with more digit should be larger. e.g. 123 > 12 > 2
- Since we should have 3 numbers, we need to split string, and may not have the most digit.
- Method1: We can try all case of formation of 3 number, and then add and have the sum
- Method2: 
	Find the biggest number it can form, and add the remaining 2.
	More Tips:
		- The biggest number you can form must not exceed n-2 digit, where n is the length of string

*/
/*
100000010000001000000
*/