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

public class Main {

   // static class Scanner {
   // StreamTokenizer in;
   // boolean forceMode = false;
   //
   // Scanner(InputStream is, String codePage, boolean forceMode) {
   // in = new StreamTokenizer(new BufferedReader(new InputStreamReader(is)));
   // if (!forceMode) {
   // in.resetSyntax();
   // in.wordChars(33, 255);
   // in.whitespaceChars(0, 32);
   // }
   // }
   //
   // Scanner(InputStream is, String codePage) {
   // in = new StreamTokenizer(new BufferedReader(new InputStreamReader(is)));
   // if (!forceMode) {
   // in.resetSyntax();
   // in.wordChars(33, 255);
   // in.whitespaceChars(0, 32);
   // }
   // }
   //
   // String next() {
   // try {
   // in.nextToken();
   // return in.sval;
   // } catch (Exception e) {
   // throw new Error();
   // }
   // }
   //
   // int nextInt() {
   // if (forceMode) {
   // try {
   // in.nextToken();
   // return (int) in.nval;
   // } catch (Exception e) {
   // throw new Error();
   // }
   // } else {
   // return Integer.parseInt(next());
   // }
   // }
   //
   // long nextLong() {
   // if (forceMode) {
   // throw new Error("No long at force mod!");
   // } else {
   // return Long.parseLong(next());
   // }
   //
   // }
   //
   // double nextDouble() {123
   // if (forceMode) {
   // try {
   // in.nextToken();
   // return in.nval;
   // } catch (Exception e) {
   // throw new Error();
   // }
   // } else {
   // return Double.parseDouble(next());
   // }
   // }
   // }

   static class Assertion {
      static void checkRE(boolean e) {
         if (!e) {
            throw new Error();
         }
      }

      static void checkTL(boolean e) {
         if (!e) {
            int idx = 1;
            while (idx > 0) {
               idx++;
            }
         }
      }
   }

   Scanner in;
   PrintWriter out;

   void solve() {
      String line = in.nextLine();
      int maxSize = 7;
      if (line.length() > 3 * maxSize) {
         out.println(-1);
         return;
      }
      int maxSum = -1;
      for (int len1 = 1; len1 <= Math.min(line.length(),maxSize); len1++) {
         for (int len2 = 1; len2 <= maxSize; len2++) {
            int num1 = parse(line.substring(0, len1));
            int num2 = -1;
            if (len1+len2<=line.length()){
                num2 = parse(line.substring(len1, len1 + len2));
            }else{
               break;
            }
            int num3 = parse(line.substring(len1 + len2, line.length()));
            if (num1 >= 0 && num2 >= 0 && num3 >= 0) {
               maxSum = Math.max(maxSum, num1 + num2 + num3);
            }
         }
      }
      out.println(maxSum);
   }

   int parse(String line) {
      if (line.length()==0){
         return -1;
      }
      if (line.charAt(0) == '0' && line.length()>1) {
         return -1;
      }else if (line.length()>7){
         return -1;
      }else{
         int num = Integer.parseInt(line);
         if (num>=0 && num<=1000000){
            return num;
         }else{
            return -1;
         }
      }
   }

   final static String fileName = "";

   void run() {
      // try {
      // in = new Scanner(new FileInputStream(fileName + ".in"), "ISO-8859-1");
      // out = new PrintWriter(fileName + ".out", "ISO-8859-1");
      // } catch (FileNotFoundException e) {
      // throw new Error(e);
      //
      // } catch (UnsupportedEncodingException e) {
      // throw new Error(e);
      // }
      in = new Scanner(System.in);
      out = new PrintWriter(System.out);
      try {
         solve();
      } catch (Exception e) {
         throw new Error(e);
      } finally {
         out.close();
      }
   }

   public static void main(String[] args) {
      new Main().run();
   }
}