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;
int inf_int = 2e9;
long long inf_ll = 2e18;
const double pi = 3.1415926535898;
template <typename T>
void prin(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i];
    if (i < a.size() - 1)
      cout << " ";
    else
      cout << "\n";
  }
}
template <typename T>
void prin(set<T>& a) {
  for (auto it = a.begin(); it != a.end(); it++) {
    cout << *it << " ";
  }
}
template <typename T>
void prin_new_line(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << "\n";
  }
}
template <typename T, typename T1>
void prin_new_line(vector<pair<T, T1> >& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i].first << " " << a[i].second << "\n";
  }
}
int sum_vec(vector<int>& a) {
  int s = 0;
  for (int i = 0; i < a.size(); i++) {
    s += a[i];
  }
  return s;
}
template <typename T>
T max(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = max(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = min(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <typename T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
void solve() {
  string a;
  cin >> a;
  if (a.size() < 3) {
    cout << -1;
    return;
  }
  int n = a.size();
  long long ans = -1;
  for (int i = 0; i < n - 2; i++) {
    string a1 = a.substr(0, i + 1);
    if (0) cout << i << " " << a1 << endl;
    if (a1.size() > 1 && a1[0] == '0') continue;
    if (a1.size() > 7) continue;
    for (int e = i + 1; e < n - 1; e++) {
      string b1 = a.substr(i + 1, e - i);
      if (b1.size() > 1 && b1[0] == '0') continue;
      if (0) cout << "\t" << e << " " << b1;
      string c1 = a.substr(e + 1, n - e - 1);
      if (c1.size() > 1 && c1[0] == '0') continue;
      if (0) cout << " " << c1 << endl;
      if (b1.size() > 7) continue;
      if (c1.size() > 7) continue;
      long long A = 0;
      for (int f = 0; f < a1.size(); f++) {
        A = A * 10 + (a1[f] - '0');
      }
      long long B = 0;
      for (int f = 0; f < b1.size(); f++) {
        B = B * 10 + (b1[f] - '0');
      }
      long long C = 0;
      for (int f = 0; f < c1.size(); f++) {
        C = C * 10 + (c1[f] - '0');
      }
      if (A <= 1000000 && B <= 1000000 && C <= 1000000) {
        ans = max(ans, A + B + C);
      }
    }
  }
  cout << ans;
}
int main() {
  if (!0) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  int t = 1;
  while (t--) solve();
  return 0;
}