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.lang.*;
public class Robote{
public static void main(String[]args){
Scanner i = new Scanner(System.in);
String x = i.next();
ArrayList<String> q1 = new ArrayList<String>();
ArrayList<Long> h = new ArrayList<Long>();
ArrayList<Integer> a1 = new ArrayList<Integer>();
ArrayList<Integer> a2 = new ArrayList<Integer>();
if(x.length()< 3|| x.length() > 21||( x.length() >= 4 && x.charAt(0) == x.charAt(1) &&  x.charAt(0) == x.charAt(2)&& x.charAt(0) == '0'))
System.out.print(-1);
else if(x.length() <= 21){
    long max1 =0;

    if(x.length() -2 < 7){
        int lon = x.length()-2;
    int z =0;

    for(int f =0 ;f < 3;f++){
        StringBuilder q = new StringBuilder(x);
        long c = Long.parseLong(x.substring(z,z+lon));
        q = q.delete(z,z+lon);
        String v = ""+q;
            long  to = c + Long.parseLong(""+v.charAt(0)) + Long.parseLong(""+v.charAt(1));
            if(to > max1)
            max1 = to;

            z++;
            }
            System.out.print(max1);
        }
else {
          for(int a = 0 ; a < x.length() ; a++ )
          {
             for( int z = 1 ; z <= x.length() - a ; z++ )
             {
          String  sub = x.substring(a, a+z);
    if(!(sub.length()  > 7   ||(sub.charAt(0) == '0'&& sub.length()>1)) && !(sub.length()  == 7  && Long.parseLong(sub) != 1000000)){
              q1.add(sub);
               a1.add(a);
               a2.add(a+z-1);
  }
      }
          }
long max3 = -1;
long too =0;
for(int e = 0; e < q1.size();e++){
too=0;
    for(int e1 = e+1;e1< q1.size();e1++){
too=0;
        for(int e2 = e1 +1;e2<q1.size();e2++){
too =0;
if(q1.get(e).length()+q1.get(e1).length()+ q1.get(e2).length() == x.length()){

if((a1.get(e1) > a2.get(e)&& a2.get(e1)< a1.get(e2))||(a1.get(e) > a2.get(e1)&& a2.get(e)< a1.get(e2))||(a1.get(e2) > a2.get(e)&& a2.get(e2)< a1.get(e1))||(a1.get(e) > a2.get(e2)&& a2.get(e)< a1.get(e1)) ){
too = Long.parseLong(q1.get(e)) + Long.parseLong(q1.get(e1))+Long.parseLong(q1.get(e2));


            if(too > max3)
            max3 = too;

            }

                }

            }
        }

    }

if(q1.size() >0 && max3 != -1)
System.out.print(max3);
else
System.out.print(-1);

    }

}


}
}