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 CPP):

Solution:
#include <bits/stdc++.h>
int l, i, j, k, h;
bool flag;
int A[50], B[50], C[50], D[50], E[50], Ans[50];
char S[50];
bool check() {
  int i;
  if (A[0] > E[0]) return 0;
  if (A[0] == E[0]) {
    for (i = A[0]; i; --i) {
      if (A[i] > E[i]) return 0;
      if (A[i] < E[i]) break;
    }
  }
  if (B[0] > E[0]) return 0;
  if (B[0] == E[0]) {
    for (i = B[0]; i; --i) {
      if (B[i] > E[i]) return 0;
      if (B[i] < E[i]) break;
    }
  }
  if (C[0] > E[0]) return 0;
  if (C[0] == E[0]) {
    for (i = C[0]; i; --i) {
      if (C[i] > E[i]) return 0;
      if (C[i] < E[i]) break;
    }
  }
  return 1;
}
bool big() {
  int i;
  if (D[0] > Ans[0]) return 1;
  if (D[0] < Ans[0]) return 0;
  for (i = D[0]; i; --i) {
    if (D[i] > Ans[i]) return 1;
    if (D[i] < Ans[i]) return 0;
  }
  return 0;
}
int main() {
  scanf("%s", S);
  l = strlen(S);
  E[0] = 7, E[7] = 1;
  flag = 0;
  for (j = 1; j < l; ++j)
    for (k = j + 1; k < l; ++k) {
      memset(A, 0, sizeof(A));
      memset(B, 0, sizeof(B));
      memset(C, 0, sizeof(C));
      memset(D, 0, sizeof(D));
      A[0] = j;
      for (h = 1; h <= A[0]; ++h) A[h] = S[j - h] - '0';
      if (A[A[0]] == 0 && A[0] != 1) continue;
      B[0] = k - j;
      for (h = 1; h <= B[0]; ++h) B[h] = S[k - h] - '0';
      if (B[B[0]] == 0 && B[0] != 1) continue;
      C[0] = l - k;
      for (h = 1; h <= C[0]; ++h) C[h] = S[l - h] - '0';
      if (C[C[0]] == 0 && C[0] != 1) continue;
      for (; A[A[0]] == 0 && A[0] > 1;) --A[0];
      for (; B[B[0]] == 0 && B[0] > 1;) --B[0];
      for (; C[C[0]] == 0 && C[0] > 1;) --C[0];
      if (!check()) continue;
      D[0] = A[0];
      if (B[0] > D[0]) D[0] = B[0];
      if (C[0] > D[0]) D[0] = C[0];
      for (h = 1; h <= D[0]; ++h) D[h] = A[h] + B[h] + C[h];
      for (h = 1; h < D[0]; ++h) {
        D[h + 1] += D[h] / 10;
        D[h] %= 10;
      }
      for (; D[D[0]] >= 10;) {
        D[D[0] + 1] = D[D[0]] / 10;
        D[D[0]] %= 10;
        ++D[0];
      }
      if (big()) memcpy(Ans, D, sizeof(Ans));
      flag = 1;
    }
  if (!flag)
    printf("-1\n");
  else {
    for (i = Ans[0]; i; --i) printf("%d", Ans[i]);
    printf("\n");
  }
  return 0;
}