#include <bits/stdc++.h>
using namespace std;
int str2num(string &s) {
  stringstream ss(s);
  int ret;
  ss >> ret;
  return ret;
}
bool valid(string &s) {
  int n = s.size();
  if (s[0] == '0') return n == 1;
  if (s.size() > 7) return false;
  int x = str2num(s);
  return x <= 1000000;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  int n = s.size(), ret = -1;
  for (int a = 1; a <= n; a++)
    for (int b = 1; b <= n; b++) {
      int c = n - a - b;
      if (c > 0) {
        string p = s.substr(0, a), q = s.substr(a, b), r = s.substr(a + b);
        if (valid(p) && valid(q) && valid(r)) {
          ret = max(ret, str2num(p) + str2num(q) + str2num(r));
        }
      }
    }
  cout << ret << endl;
  return 0;
}
