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 <class F, class T>
T convert(F a, int p = -1) {
  stringstream ss;
  if (p >= 0) ss << fixed << setprecision(p);
  ss << a;
  T r;
  ss >> r;
  return r;
}
template <class T>
T gcd(T a, T b) {
  T r;
  while (b != 0) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T cube(T x) {
  return x * x * x;
}
template <class T>
int getbit(T s, int i) {
  return (s >> i) & 1;
}
template <class T>
T onbit(T s, int i) {
  return s | (T(1) << i);
}
template <class T>
T offbit(T s, int i) {
  return s & (~(T(1) << i));
}
template <class T>
int cntbit(T s) {
  return s == 0 ? 0 : cntbit(s >> 1) + (s & 1);
}
const long double PI = acos(-1.0);
const long double eps = 1e-9;
const int dr[] = {-1, 0, +1, 0};
const int dc[] = {0, +1, 0, -1};
const int inf = (int)1e9 + 5;
const long long linf = (long long)1e16 + 5;
const long long mod = (long long)1e9 + 7;
string s;
int sum(string s1) {
  int ans = 0;
  int nhan = 1;
  for (int i = (((int)(s1).size())) - 1; i >= 0; --i) {
    ans += nhan * (s1[i] - '0');
    nhan *= 10;
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  int res = -1;
  for (int i = (0); i <= (((int)(s).size()) - 2); ++i) {
    for (int j = (i + 1); j <= (((int)(s).size()) - 2); ++j) {
      int temp;
      string s1 = s.substr(0, i + 1);
      string s2 = s.substr(i + 1, j - i);
      string s3 = s.substr(j + 1, ((int)(s).size()) - j);
      if (((int)(s1).size()) > 7 || ((int)(s2).size()) > 7 ||
          ((int)(s3).size()) > 7)
        continue;
      if (((int)(s1).size()) == 7 && s1 > "1000000") continue;
      if (((int)(s2).size()) == 7 && s2 > "1000000") continue;
      if (((int)(s3).size()) == 7 && s3 > "1000000") continue;
      if (s1[0] == '0' && ((int)(s1).size()) != 1) continue;
      if (s2[0] == '0' && ((int)(s2).size()) != 1) continue;
      if (s3[0] == '0' && ((int)(s3).size()) != 1) continue;
      temp = sum(s1) + sum(s2) + sum(s3);
      res = max(temp, res);
    }
  }
  cout << res << '\n';
}