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.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
/**
 * Date     : 14.04.2012
 * Time     : 22:06:53
 * Email    : denys.astanin@gmail.com
 */

public class s115_a {
	public static void main(String[] args) throws IOException {
		new s115_a().run();
	}



	Writer writer;
	Reader reader;
	int first 	= 0;
	int second 	= 0;
	int third   = 0;
	String line;
	void run() throws IOException {
		boolean oj = System.getProperty("ONLINE_JUDGE") != null;
		reader = oj ? new InputStreamReader(System.in, "ISO-8859-1")
				: new FileReader("input/is115_a.txt");
		BufferedReader br = new BufferedReader(reader);
		writer = new OutputStreamWriter(System.out, "ISO-8859-1");
		PrintWriter out = new PrintWriter(writer);
		line = br.readLine();
		
		int maxSum = -1;
		int fl = 1;
		int sl = 1;
		while (true) {
			int fstart = 0;
			int sstart = fstart + fl;
			sl = 1;
			if (fl > line.length() - 2) {
				break;
			}
			while (true) {
				int tstart = sstart + sl;
				String fs = getPartOfString(fstart, fl, line);
				String ss = getPartOfString(sstart, sl, line);
				String ts = getPartOfString(tstart, line.length() - tstart, line);
				if (ss == null || ts == null || ts.isEmpty()) {
					break;
				}
				

				if ((!fs.startsWith("0") || (fs.startsWith("0") && fs.length() == 1))
						 && (!ss.startsWith("0") || (ss.startsWith("0") && ss.length() == 1))
						 && (!ts.startsWith("0") || (ts.startsWith("0") && ts.length() == 1))) {
					fs = fs.replaceFirst("^00+", "");
					ss = ss.replaceFirst("^00+", "");
					ts = ts.replaceFirst("^00+", "");
					try {
						int f = Integer.valueOf(fs);
						int s = Integer.valueOf(ss);
						int t = Integer.valueOf(ts);
						if (f <= 1e6 && s <= 1e6 && t <= 1e6 ) {
							maxSum = Math.max(maxSum, f + s + t);
						}
					} catch (Exception e) {
//						e.printStackTrace();
					}
				}
				sl++;
			}
			fl++;
		}
		out.println(maxSum);
		out.flush();
		out.close();
	}
	String getPartOfString(int startIndex, int length, String str) {
		if (startIndex + length > str.length()) {
			return null;
		}
		return str.substring(startIndex, startIndex + length);
	}
}