#include <bits/stdc++.h>
using namespace std;
long long StringToNumber(string &s) {
  stringstream ss(s);
  long long result;
  return ss >> result ? result : 0;
}
int main() {
  long long max = 0;
  bool thereIsMax = false;
  string s;
  cin >> s;
  for (unsigned int i = 1; i < s.length(); i++) {
    for (unsigned int j = i + 1; j < s.length(); j++) {
      string s1 = s.substr(0, i);
      string s2 = s.substr(i, j - i);
      string s3 = s.substr(j, s.length() - j);
      if (s1.length() >= 2 && s1[0] == '0') continue;
      if (s2.length() >= 2 && s2[0] == '0') continue;
      if (s3.length() >= 2 && s3[0] == '0') continue;
      long long num1 = StringToNumber(s1), num2 = StringToNumber(s2),
                num3 = StringToNumber(s3);
      if ((num1 > 1000000) || (num2 > 1000000) || (num3 > 1000000)) {
        continue;
      }
      if ((s1.length() > 7) || (s2.length() > 7) || (s3.length() > 7)) {
        continue;
      }
      long long sum = num1 + num2 + num3;
      thereIsMax = true;
      if (sum > max) {
        max = sum;
        thereIsMax = true;
      }
    }
  }
  if (!thereIsMax) {
    cout << "-1" << endl;
    return 0;
  }
  cout << max << endl;
  return 0;
}
