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.*;
import java.util.Map.Entry;

// 115
public class Main {
	
	void D(){
		
	}
	
	void C(){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		Figure[] figs = new Figure[n];
		for(int i=0; i<n; i++)	figs[i] = new Figure(sc.nextInt(), sc.nextInt());
		Arrays.sort(figs);
		int t=sc.nextInt();
		long[] p = new long[t];
		for(int i=0; i<t; i++)	p[i] = sc.nextLong();
		long score=0,fac=1;
		int pc=0;
		for(int i=0; i<n; i++){
			for(int j=0; j<=figs[i].k;){
				if(figs[i].k-j < p[pc]){
					score += fac*(long)figs[i].c*(long)(figs[i].k-j);
					p[pc] -= (figs[i].k-j);
					//System.out.println("SCORE:"+score+"FAC:"+fac);
					break;
				}else{
					score += fac*(long)figs[i].c*p[pc];
					j+=p[pc];
					//System.out.println("SCORE:"+score+"FAC:"+fac+"PC/PL"+pc+"/"+p.length);
					if(pc==p.length-1){
						p[pc] = 1000000000000L;
					}else{
						pc++;
						fac++;
					}
				}
			}
		}
		System.out.println(score);
	}
	
	class Figure implements Comparable<Figure>{
		int k,c;
		Figure(int k, int c){
			this.k=k;	this.c=c;
		}
		@Override
		public int compareTo(Figure arg0) {
			if(this.c > arg0.c)	return -1;
			if(this.c < arg0.c)	return 1;
			if(this.k > arg0.k)	return -1;
			if(this.k < arg0.k)	return 1;
			return 0;
		}
	}
	
	void B(){
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		HashMap<String,Integer> map = new HashMap<String,Integer>();
		for(int i=0; i<n; i++)	map.put(sc.next(), sc.nextInt());
		int len=map.size();
		Iterator it = map.entrySet().iterator();
		String[] names = new String[len];
		int[] scores = new int[len];
		int c=0;
		while(it.hasNext()){
			Map.Entry<String, Integer> en = (Entry<String, Integer>) it.next();
			names[c] = en.getKey();
			scores[c] = en.getValue();
			c++;
		}
		System.out.println(len);
		for(int i=0; i<len; i++){
			int h=0,l=0;
			for(int j=0; j<len; j++){
				if(scores[i] >= scores[j])	h++;
				if(scores[i] < scores[j])	l++;
			}
			//debug
			//System.out.println(names[i]+" H:"+(double)h/(double)len+"L:"+(double)l/(double)len+" len"+(h+l));
			if((double)h/(double)len>=0.99){
				System.out.println(names[i]+" "+"pro");
				continue;
			}
			if((double)h/(double)len>=0.9 && (double)l/(double)len>0.01){
				System.out.println(names[i]+" "+"hardcore");
				continue;
			}
			if((double)h/(double)len>=0.8 && (double)l/(double)len>0.1){
				System.out.println(names[i]+" "+"average");
				continue;
			}
			if((double)h/(double)len>=0.5 && (double)l/(double)len>0.2){
				System.out.println(names[i]+" "+"random");
				continue;
			}
			if((double)l/(double)len>0.5){
				System.out.println(names[i]+" "+"noob");
				continue;
			}
			System.out.println(names[i]+" ");
		}
	}
	
	class Score{
		String name;
		int score;
		Score(String name, int score){
			this.name=name;	this.score=score;
		}
	}
	
	void A(){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int len = s.length();
		int as=0,bs=0,cs=0,max=-1;
		for(int ap=0,al=1; al<=len-2; al++){
			for(int bp=ap+al, bl=1; al+bl<=len-1; bl++){
				int cp=bp+bl, cl=len-cp;
				int a=Sum(s,ap,al), b=Sum(s,bp,bl), c=Sum(s,cp,cl);
				//debug
				//System.out.println("A:"+a+" B:"+b+" C:"+c);
				if(a>=0 && b>=0 && c>=0){
					if(a+b+c>max)	max=a+b+c;
				}
			}
		}
		System.out.println(max);
	}
	
	int Sum (String s, int a, int b){
		if(b>1 && Integer.parseInt(""+s.charAt(a))==0)	return -1;
		if(b>7)	return -1;
		int sum=0;
		for(int i=a; i<a+b; i++){
			//debug
			//System.out.print(""+s.charAt(i));
			sum = sum*10+Integer.parseInt(""+s.charAt(i));
		}
		//debug
		//System.out.println();
		if(sum>1000000)	return -1;
		return sum;
	}
	
	
	public static void main(String[] args) {
		new Main().A();
	}
}