#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, l;
  string input;
  while (cin >> input) {
    long ans = -1;
    l = input.length();
    for (i = 1; i < l; i++) {
      for (j = i + 1; j < l; j++) {
        long a = 0, b = 0, c = 0;
        if (input[0] == '0' && i > 1)
          continue;
        else if (input[i] == '0' && i + 1 < j)
          continue;
        else if (input[j] == '0' && j + 1 < l)
          continue;
        else {
          bool ok = true;
          int pos = 0;
          while (pos < i) {
            a = a * 10 + input[pos] - '0';
            pos++;
            if (a > 1000000) {
              ok = false;
              break;
            }
          }
          if (ok == true) {
            while (pos < j) {
              b = b * 10 + input[pos] - '0';
              pos++;
              if (b > 1000000) {
                ok = false;
                break;
              }
            }
            if (ok == true) {
              while (pos < l) {
                c = c * 10 + input[pos] - '0';
                pos++;
                if (c > 1000000) {
                  ok = false;
                  break;
                }
              }
            }
          }
          if (ok == true) {
            a = a + b + c;
            if (a > ans) ans = a;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
