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;
using int8 = int8_t;
using int16 = int16_t;
using int32 = int32_t;
using int64 = int64_t;
using uint8 = int8_t;
using uint16 = uint16_t;
using uint32 = uint32_t;
using uint64 = uint64_t;
using float32 = float;
using float64 = double;
template <typename T>
class V : public vector<T> {
 public:
  using vector<T>::vector;
  inline T& operator[](const size_t& index) { return this->at(index); }
  inline const T& operator[](const size_t& index) const {
    return this->at(index);
  }
};
template <typename T, size_t thisSize, size_t... otherSizes>
class A : public array<A<T, otherSizes...>, thisSize> {
 public:
  using array<A<T, otherSizes...>, thisSize>::array;
  inline A<T, otherSizes...>& operator[](const size_t& index) {
    return this->at(index);
  }
  inline const A<T, otherSizes...>& operator[](const size_t& index) const {
    return this->at(index);
  }
};
template <typename T, size_t thisSize>
class A<T, thisSize> : public array<T, thisSize> {
 public:
  using array<T, thisSize>::array;
  inline T& operator[](const size_t& index) { return this->at(index); }
  inline const T& operator[](const size_t& index) const {
    return this->at(index);
  }
};
char buffer[1 << 20];
inline int readInt() {
  int v;
  scanf("%d", &v);
  return v;
}
inline int64 readInt64() {
  int64 v;
  scanf("%" SCNd64, &v);
  return v;
}
inline int64 readUInt64() {
  uint64 v;
  scanf("%" SCNu64, &v);
  return v;
}
inline char readChar() {
  char v;
  scanf("%c", &v);
  return v;
}
inline float64 readFloat64() {
  float64 v;
  scanf("%lf", &v);
  return v;
}
inline string readString() {
  scanf("%s", buffer);
  return string(buffer);
}
inline string readLine() {
  fgets(buffer, sizeof(buffer), stdin);
  return string(buffer);
}
inline void print(const int& v) { printf("%d", v); }
inline void print(const int64& v) { printf("%" PRId64, v); }
inline void print(const uint64& v) { printf("%" PRIu64, v); }
inline void print(const char& v) { printf("%c", v); }
inline void print(const float64& v) { printf("%.20lf", v); }
inline void print(const string& v) { printf("%s", v.c_str()); }
template <typename T1, typename T2>
inline void print(const pair<T1, T2>& v) {
  print('(');
  print(v.first);
  print(", ");
  print(v.second);
  print(')');
}
inline void printLine() { print('\n'); }
template <typename T>
inline void printLine(const T& v) {
  print(v);
  print('\n');
}
template <typename T>
inline void printLine(const V<T>& v) {
  for (int i = 0; i < int(v.size()); i++) {
    if (i) print(' ');
    print(v[i]);
  }
  printLine();
}
template <typename T>
inline void printLine(const V<V<T>>& v) {
  for (const auto& x : v) {
    printLine(x);
  }
}
template <typename T>
inline void logln_(const T& v) {
  print("log: ");
  printLine(v);
}
template <typename T>
inline void logln_(const V<T>& v) {
  print("log: ");
  printLine(v);
}
template <typename T>
inline void logln_(const V<V<T>>& v) {
  for (const auto& x : v) {
    logln_(x);
  }
}
void solve();
int main() {
  srand(time(nullptr));
  solve();
  return 0;
}
const int base = 1000 * 1000 * 1000;
V<int> readBig(string&& s) {
  V<int> a;
  for (int i = (int)s.length(); i > 0; i -= 9)
    if (i < 9)
      a.push_back(atoi(s.substr(0, i).c_str()));
    else
      a.push_back(atoi(s.substr(i - 9, 9).c_str()));
  return a;
}
V<int> readBig(string& s) {
  V<int> a;
  for (int i = (int)s.length(); i > 0; i -= 9)
    if (i < 9)
      a.push_back(atoi(s.substr(0, i).c_str()));
    else
      a.push_back(atoi(s.substr(i - 9, 9).c_str()));
  return a;
}
void printBig(V<int>& a) {
  printf("%d", a.empty() ? 0 : a.back());
  for (int i = (int)a.size() - 2; i >= 0; --i) printf("%09d", a[i]);
}
void addBig(V<int>& a, V<int>& b) {
  int carry = 0;
  for (size_t i = 0; i < max(a.size(), b.size()) || carry; ++i) {
    if (i == a.size()) a.push_back(0);
    a[i] += carry + (i < b.size() ? b[i] : 0);
    carry = a[i] >= base;
    if (carry) a[i] -= base;
  }
}
int cmpBig(V<int>& a, V<int>& b) {
  if (int(a.size()) < int(b.size())) return -1;
  if (int(a.size()) > int(b.size())) return 1;
  for (int i = int(a.size()) - 1; i >= 0; i--) {
    if (a[i] < b[i]) return -1;
    if (a[i] > b[i]) return 1;
  }
  return 0;
}
void solve() {
  auto LIMIT = readBig("1000000");
  V<int> ans;
  string s = readString();
  for (int a = 1; a <= int(s.size()); a++)
    for (int b = 1; b <= int(s.size()); b++) {
      int c = int(s.size()) - a - b;
      if (c > 0 && a + b + c == int(s.size())) {
        string sa = s.substr(0, a);
        string sb = s.substr(a, b);
        string sc = s.substr(a + b, c);
        if ((sa[0] == '0' && a != 1) || (sb[0] == '0' && b != 1) ||
            (sc[0] == '0' && c != 1)) {
          continue;
        }
        auto va = readBig(sa);
        auto vb = readBig(sb);
        auto vc = readBig(sc);
        if (cmpBig(va, LIMIT) > 0 || cmpBig(vb, LIMIT) > 0 ||
            cmpBig(vc, LIMIT) > 0) {
          continue;
        }
        addBig(va, vb);
        addBig(va, vc);
        if (int(ans.size()) == 0 || cmpBig(ans, va) < 0) {
          ans = va;
        }
      }
    }
  if (int(ans.size()) == 0) {
    printLine(-1);
  } else {
    printBig(ans);
    printLine();
  }
}