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.io.BufferedReader;
import java.io.InputStreamReader;

public class A { // Robot Bicorn Attack

	private static final boolean DEBUG = false;

	public static void main( final String[] args ) throws Exception {
		final BufferedReader br = new BufferedReader( new InputStreamReader( System.in ) );
		final String s = br.readLine();
		System.out.println( solve( s ) );
	}

	private static final long MAX = 1000000;

	public static long solve( final String s ) {
		long res = -1;
		if ( s.length() < 3 ) return res;
		for ( int len1 = 1; len1 < s.length(); ++len1 ) {
			for ( int len2 = 1; len2 < s.length(); ++len2 ) {
				final int len3 = s.length() - len1 - len2;
				if ( len3 <= 0 ) continue;

				final String ps1 = s.substring( 0, len1 );
				if ( ps1.charAt( 0 ) == '0' && ps1.length() > 1 ) continue;

				final String ps2 = s.substring( len1, len1 + len2 );
				if ( ps2.charAt( 0 ) == '0' && ps2.length() > 1 ) continue;

				final String ps3 = s.substring( len1 + len2 );
				if ( ps3.charAt( 0 ) == '0' && ps3.length() > 1 ) continue;
				if ( DEBUG ) System.out.printf( "ps1='%s', ps2='%s', ps3='%s'\n", ps1, ps2, ps3 );
				try {
					final long p1 = Long.parseLong( ps1 );
					final long p2 = Long.parseLong( ps2 );
					final long p3 = Long.parseLong( ps3 );
					if ( p1 <= MAX && p2 <= MAX && p3 <= MAX && p1 + p2 + p3 > res )
						res = p1 + p2 + p3;
				} catch ( final NumberFormatException nfe ) {
					// simply not valid
				}
			}
		}
		return res;
	}
}