#include <bits/stdc++.h>
using namespace std;
string s;
int c;
vector<int> A;
int dp[105][105];
int robot(int i, int j) {
  if (j == s.length() - 1 || i >= j) return 0;
  int& ref = dp[i][j];
  if (ref != -1) return ref;
  int s1, s2, s3;
  string ss1, ss2, ss3;
  regex syn("^0[0-9][0-9]*$");
  ss1 = s.substr(0, i + 1);
  ss2 = s.substr(i + 1, j - i);
  ss3 = s.substr(j + 1, s.length() - j);
  s1 = atol(ss1.c_str());
  s2 = atol(ss2.c_str());
  s3 = atol(ss3.c_str());
  if (regex_match(ss1, syn) || regex_match(ss2, syn) || regex_match(ss3, syn) ||
      ss1.length() > 7 || ss2.length() > 7 || ss3.length() > 7 ||
      s1 > 1000000 || s2 > 1000000 || s3 > 1000000)
    return ref = max(robot(i + 1, j), robot(i, j + 1));
  return ref = max((s1 + s2 + s3), max(robot(i + 1, j), robot(i, j + 1)));
}
int main() {
  cin >> s;
  memset(dp, -1, sizeof dp);
  if (s == "000")
    cout << 0 << endl;
  else if (s.length() == 1 || s.length() == 2)
    cout << -1 << endl;
  else {
    int n = robot(0, 1);
    if (n == 0)
      cout << "-1";
    else
      cout << n;
  }
}
