#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, n1, n2, n3, t, s;
  string str, s1, s2, s3;
  vector<int> v;
  cin >> str;
  if (str.length() < 2 || str.length() > 21) {
    cout << "-1\n";
    return 0;
    ;
  }
  n = str.length() - 2;
  t = n;
  for (int i = 1; i <= n; i++, t--) {
    s = t;
    for (int j = 1; j <= t; j++, s--) {
      s1 = str.substr(0, i);
      s2 = str.substr(i, j);
      s3 = str.substr(i + j, s);
      stringstream(s1) >> (n1);
      stringstream(s2) >> (n2);
      stringstream(s3) >> (n3);
      if ((s1.length() == 1 || s2.length() == 1 || s3.length() == 1) &&
          (n1 <= 1000000 && n2 <= 1000000 && n3 <= 1000000)) {
        if (s1.length() > 1 && s1[0] == '0') continue;
        if (s2.length() > 1 && s2[0] == '0') continue;
        if (s3.length() > 1 && s3[0] == '0') continue;
        v.push_back(n1 + n2 + n3);
      } else if (s1[0] != '0' && s2[0] != '0' && s3[0] != '0' &&
                 n1 <= 1000000 && n2 <= 1000000 && n3 <= 1000000)
        v.push_back(n1 + n2 + n3);
    }
  }
  if (v.empty())
    cout << "-1\n";
  else
    cout << *max_element(v.begin(), v.end()) << endl;
  return 0;
}
