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>
using namespace std;
template <typename T>
inline T GCD(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    a = a % b;
    swap(a, b);
  }
  return a;
}
template <typename T>
inline T LCM(T x, T y) {
  T tp = GCD(x, y);
  if ((x / tp) * 1. * y > 9e18) return 9e18;
  return (x / tp) * y;
}
template <typename T>
inline T BigMod(T A, T B, T M) {
  T ret = 1;
  while (B) {
    if (B & 1) ret = (ret * A) % M;
    A = (A * A) % M;
    B = B >> 1;
  }
  return ret;
}
template <typename T>
inline T InvMod(T A, T M) {
  return BigMod(A, M - 2, M);
}
long long gcdr(long long a, long long b) {
  if (a == 0) return b;
  return gcdr(b % a, a);
}
long long poW(long long x, long long n) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return poW(x * x, n / 2);
  else
    return x * poW(x * x, ((n - 1) / 2));
}
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
void FastIO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);
}
int main() {
  FastIO();
  long long t, i, j, n, x, y;
  t = 1;
  while (t--) {
    string s;
    cin >> s;
    long long zeros = 0;
    long long sz = s.size();
    reverse(s.begin(), s.end());
    if (sz < 3) {
      cout << "-1" << endl;
      continue;
    }
    long long ans = -1, flag = 0, last = sz - 1;
    for (i = 1; i <= 7 && i < sz; i++) {
      long long cnt = 0;
      for (long long ii = last; ii > (last - i); ii--) {
        if (s[ii] == '0') {
          cnt++;
        } else {
          break;
        }
      }
      if (cnt > 1) {
        continue;
      }
      if (cnt == 1 && i > 1) {
        continue;
      }
      long long exp = i - 1;
      long long first = 0, second = 0, third = 0;
      for (long long ii = last; ii > (last - i) && ii > 0; ii--) {
        first += ((s[ii] - '0') * poW(10, exp));
        exp--;
      }
      for (j = 1; j <= 7 && j < sz; j++) {
        long long zero = 0;
        second = 0;
        third = 0;
        for (long long jj = last - i; jj > (last - i - j) && jj > 0; jj--) {
          if (s[jj] == '0') {
            zero++;
          } else {
            break;
          }
        }
        if (zero > 1) {
          continue;
        }
        if (zero == 1 && j > 1) {
          continue;
        }
        exp = j - 1;
        for (long long jj = last - i; jj > (last - i - j); jj--) {
          second += ((s[jj] - '0') * poW(10, exp));
          exp--;
        }
        long long used = i + j;
        long long rem = sz - used;
        if (rem > 7 || rem < 1) {
          continue;
        }
        exp = rem - 1;
        zero = 0;
        for (long long k = last - i - j; k >= 0; k--) {
          if (s[k] == '0') {
            zero++;
          } else {
            break;
          }
        }
        if (zero > 1) {
          continue;
        } else if (zero == 1 && rem > 1) {
          continue;
        }
        for (long long k = last - i - j; k >= 0; k--) {
          third += ((s[k] - '0') * poW(10, exp));
          exp--;
        }
        if (first > 1000000 || second > 1e6 || third > 1e6) {
          continue;
        }
        flag = 1;
        ans = max(ans, first + second + third);
      }
    }
    if (flag) {
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}