#include <bits/stdc++.h>
using namespace std;
int main() {
  string x;
  stringstream ss;
  cin >> x;
  vector<int> arr1, arr2, arr3, arr4;
  int n, m, c;
  string g;
  if (x.size() > 21) {
    cout << "-1";
    return 0;
  }
  for (int a = 1; a < x.size() - 1; a++) {
    for (int b = a + 1; b < x.size(); b++) {
      ss << x.substr(0, a - 0);
      ss >> n;
      ss.clear();
      if (x.substr(0, a).size() >= 2 && x.substr(0, a)[0] == '0') continue;
      if (n > 1000000) continue;
      ss << x.substr(a, b - a);
      ss >> m;
      ss.clear();
      if (x.substr(a, b - a).size() >= 2 && x.substr(a, b - a)[0] == '0')
        continue;
      if (m > 1000000) continue;
      ss << x.substr(b, x.size() - b);
      ss >> c;
      ss.clear();
      if (x.substr(b, x.size() - b).size() >= 2 &&
          x.substr(b, x.size() - b)[0] == '0')
        continue;
      if (c > 1000000) continue;
      arr4.push_back(n + m + c);
    }
  }
  sort(arr4.begin(), arr4.end());
  if (arr4.size() != 0)
    cout << arr4[arr4.size() - 1];
  else
    cout << -1;
  return 0;
}
