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.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.List;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream stdin = System.in;
        OutputStream stdout = System.out;

        /*
         * InputStream fileIn = new FileInputStream(new File("input.txt"));
         * OutputStream fileOut = new FileOutputStream(new File("output.txt"));
         */

        InputReader in = new InputReader(stdin);
        OutputWriter out = new OutputWriter(stdout);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
        String s = in.readString();
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < s.length(); i++) {
            for (int j = i; j < s.length(); j++) {
                try {
                    String aaa = s.substring(0, i);
                    String bbb = s.substring(i, j);
                    String ccc = s.substring(j, s.length());
                    int a = Integer.parseInt(aaa);
                    int b = Integer.parseInt(bbb);
                    int c = Integer.parseInt(ccc);
                    String aa = Integer.toString(a);
                    String bb = Integer.toString(b);
                    String cc = Integer.toString(c);
                    if (a <= 1000000 && b <= 1000000 && c <= 1000000 && aa.length() + bb.length() + cc.length() == s.length() && aa.length() == aaa.length() && bb.length() == bbb.length() && cc.length() == ccc.length()) {
                        max = Math.max(max, a + b + c);
                    }
                }
                catch (Exception e) {
                }
            }
        }
        if (max == Integer.MIN_VALUE)
            out.printLine(-1);
        else
            out.printLine(max); 
    }
    
    public void solveB(int testNumber, InputReader in, OutputWriter out) {
        ArrayList<Player>list = new ArrayList<Task.Player>();
        int n = in.readInt();
        HashMap<String, Integer>map = new HashMap<String, Integer>();
        
        for (int i = 0; i < n; i++) {
            String name = in.readString();
            int point = in.readInt();
            if (map.containsKey(name)) {
                map.put(name, Math.max(point, map.get(name)));
            }
            else {
                map.put(name, point);
            }
        }
        
        String[]names = new String[map.size()];
        Integer[]points = new Integer[map.size()];
        map.keySet().toArray(names);
        map.values().toArray(points);
        for (int i = 0; i < names.length; i++) {
            String currName = names[i];
            int better = 0;
            int worst = 0;
            for (int j = 0; j < points.length; j++) {
                if (points[j] > points[i]) {
                    better++;
                }
                if (points[j] <= points[i]) {
                    worst++;
                }
            }
            double Bpercent = (double)((double)((double)better / (double)map.size()) * (double)100);
            double Wpercent = (double)((double)((double)worst / (double)map.size()) * (double)100);
            if (Wpercent > 99 && Bpercent < 1) {
                Player p = new Player();
                p.rank = "pro";
                p.name = names[i];
                list.add(p);
                continue;
            }

            if (Wpercent > 90 && Bpercent < 1) {
                Player p = new Player();
                p.rank = "hardcore";
                p.name = names[i];
                list.add(p);
                continue;
            }

            if (Wpercent > 80 && Bpercent < 10) {
                Player p = new Player();
                p.rank = "average";
                p.name = names[i];
                list.add(p);
                continue;
            }
            
            if (Wpercent < 50 && Bpercent > 20) {
                Player p = new Player();
                p.rank = "random";
                p.name = names[i];
                list.add(p);
                continue;
            }
            
            if (Wpercent > 50) {
                Player p = new Player();
                p.rank = "noob";
                p.name = names[i];
                list.add(p);
                continue;
            }           
        }
        
        Collections.sort(list);
        out.printLine(list.size());
        for (int i = 0; i < list.size(); i++) {
            out.printLine(list.get(i).name + " " + list.get(i).rank);
        }
        
        
    }
    
    class Player implements Comparable<Player>{
        String name;
        String rank;
        public int compareTo(Player o) {
            return this.name.compareTo(o.name);
        }
    }
    public String trim(String s) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '0') {
                
            }
        }
        
        return sb.toString();
    }
}

class InputReader {

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }
    
    public char readCharacter() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}

class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
        writer = new PrintWriter(outputStream);
    }

    public OutputWriter(Writer writer) {
        this.writer = new PrintWriter(writer);
    }

    public void print(Object... objects) {
        for (int i = 0; i < objects.length; i++) {
            if (i != 0)
                writer.print(' ');
            writer.print(objects[i]);
        }
    }

    public void printLine(Object... objects) {
        print(objects);
        writer.println();
    }

    public void close() {
        writer.close();
    }
}

class StringUtil {
    public static int[] prefixFunction(String s) {
        int n = s.length();
        int[] p = new int[n];
        for (int i = 1; i < n; i++) {
            int k = p[i - 1];
            while (k > 0 && s.charAt(k) != s.charAt(i)) {
                k = p[k - 1];
            }
            p[i] = k + (s.charAt(k) == s.charAt(i) ? 1 : 0);
        }
        return p;
    }

    public static int kmpMatcher(String s, String pattern) {
        int m = pattern.length();
        if (m == 0) {
            return 0;
        }
        int n = s.length();
        int[] p = prefixFunction(pattern);
        int k = 0;
        for (int i = 0; i < n; i++) {
            while (k > 0 && s.charAt(i) != pattern.charAt(k)) {
                k = p[k - 1];
            }
            if (s.charAt(i) == pattern.charAt(k)) {
                k++;
            }
            if (k == m) {
                return i - m + 1;
            }
        }
        return -1;
    }
}