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 aboRagab
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        if (check(new String[]{"12635", "0000", "00127683"})) {
            System.out.println("a7a");
        }
        Scanner in = new Scanner(System.in);
        String s = in.next();

        if (s.length() < 3) {
            System.out.println("-1");

        } else {
            String a = s.substring(0, s.length() - 2);
            String b = s.substring(s.length() - 2, s.length() - 1);
            String c = s.substring(s.length() - 1);

            String sums = "";
            String[][] ss = new String[a.length()][3];
            for (int i = 0; i < a.length(); i++) {
                String aa = s.substring(0, s.length() - 2 - i);
                String bb = s.substring(s.length() - 2 - i, s.length() - 1);
                String cc = s.substring(s.length() - 1);
                ss[i] = new String[]{aa, bb, cc};
                if (check(ss[i])) {
                    sums += sum(ss[i]) + " ";
                }
            }

            for (int i = 0; i < ss.length; i++) {
                while (true) {
                    if (ss[i][1].length() == 1) {
                        break;
                    }
                    ss[i][2] = ss[i][1].substring(ss[i][1].length() - 1) + ss[i][2];
                    ss[i][1] = ss[i][1].substring(0, ss[i][1].length() - 1);
                    if (check(ss[i])) {
                        sums += sum(ss[i]) + " ";
//                        System.out.println(ss[i][0] + " " + ss[i][1] + " " + ss[i][2] + "      " + sum(ss[i]));
                    }
                }
            }
            if (sums.length() > 0) {
                System.out.println(max(sums.substring(0, sums.length() - 1)));
            } else {
                System.out.println("-1");
            }
        }
    }

    public static long sum(String[] a) {
        long s = 0;
        try {
            for (int i = 0; i < a.length; i++) {
                s += Long.parseLong(a[i]) <= 1000000 ? Long.parseLong(a[i]) : -3000000;
            }
        } catch (Exception e) {
            return -100;
        }
        return s;
    }

    public static long max(String s) {
        String[] sums = s.split(" ");
        long max = -1;
        for (int i = 0; i < sums.length; i++) {
            if (max < Long.parseLong(sums[i]) && Long.parseLong(sums[i]) <= 3000000) {
                max = Long.parseLong(sums[i]);
            }
        }
        return max;
    }

    public static boolean check(String[] a) {
        for (int i = 0; i < a.length; i++) {
            if (a[i].length() > 1 && a[i].charAt(0) == '0') {
                return false;
            }
        }
        return true;

    }
}