#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int x = -1, y = -1, z = -1, sum = -1;
  stringstream ss;
  if (s.length() <= 21) {
    for (int i = 1; i < s.length() - 1; i++) {
      ss << s.substr(0, i);
      ss >> x;
      ss.clear();
      if (i > 1) {
        if (s[0] == '0') {
          x = -1;
        }
      }
      if (x > 1000000) {
        x = -1;
      }
      if (x != -1) {
        for (int j = 1; j < s.length() - i; j++) {
          ss << s.substr(i, j);
          ss >> y;
          ss.clear();
          if (j > 1) {
            if (s[i] == '0') {
              y = -1;
            }
          }
          if (y > 1000000) {
            y = -1;
          }
          if (y != -1) {
            ss << s.substr(i + j, s.length() - i - j);
            ss >> z;
            ss.clear();
            if (s.length() - i - j > 1) {
              if (s[i + j] == '0') {
                z = -1;
              }
            }
            if (z > 1000000) {
              z = -1;
            }
          }
          if (x != -1 && y != -1 && z != -1) {
            if (sum < x + y + z) {
              sum = x + y + z;
            }
          }
        }
      }
    }
  }
  cout << sum << "\n";
  return 0;
}
